Latest 1.0.1
Homepage https://github.com/StockX/SafeAreaInputAccessoryViewWrapperView
License MIT
Platforms ios 9.0
Authors

SafeAreaInputAccessoryViewWrapperView Logo

SafeAreaInputAccessoryViewWrapperView
Platform
Version
License

Description

SafeAreaInputAccessoryViewWrapperView is useful for wrapping a view to be used as an inputAccessoryView. Without this, setting the view as an inputAccessoryView will ignore safe area layouts. For example, the Home screen indicator on iPhone X will battle for the same spot. This class ensures that the view respects safe area layouts and does not cover up system UI elements such as the Home screen indicator on iPhone X.

Works with iOS 9.0+ and Xcode 9.0.0+.

Contents

  1. Features
  2. Usage
  3. Installation
  4. License
  5. Contact

Features

  • [x] Works with all devices running iOS 9+.
  • [x] Respects safeAreaLayoutGuide on devices running iOS 11+. For example, the wrapped view is slid up to make room for the iPhone X Home screen indicator.
  • [x] Dynamically sets the wrapped view’s height using autolayout constraints. No more setting frames manually!
  • [x] Example app with an inputAccessoryView that’s always visible, even when the keyboard is closed.

Example Project Screenshot - iPhone X
Example Project Screenshot - iPhone 8

Usage

  1. Wrap any UIView/UIButton/UILabel/etc using SafeAreaInputAccessoryViewWrapperView(for:):
SafeAreaInputAccessoryViewWrapperView(for: button)
  1. Store a reference to this somewhere in your class:
let button = UIButton(type: .system)

lazy var wrappedButton: SafeAreaInputAccessoryViewWrapperView = {
    return SafeAreaInputAccessoryViewWrapperView(for: button)
}()
  1. Return the reference in inputAccessoryView:
override var inputAccessoryView: UIView? {
    return wrappedButton
}
  1. (Optional) Always show the inputAccessoryView, even when the keyboard is closed:
override var canBecomeFirstResponder: Bool {
    return true
}

override func viewDidLoad() {
    super.viewDidLoad()
    becomeFirstResponder()
}

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:

$ gem install cocoapods

To integrate SafeAreaInputAccessoryViewWrapperView into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'SafeAreaInputAccessoryViewWrapperView'

Then, run the following command:

$ pod install

In case Xcode complains ("Cannot load underlying module for SafeAreaInputAccessoryViewWrapperView") go to Product and choose Clean (or simply press K).

Manually

If you prefer not to use CocoaPods, you can integrate SafeAreaInputAccessoryViewWrapperView into your project manually.

License

SafeAreaInputAccessoryViewWrapperView is developed by Jeff Burt at StockX and is released under the MIT license. See the LICENSE file for details.

Contact

Feel free to follow me on my personal Twitter account. If you find any problems with the project or have ideas to enhance it, feel free to open a GitHub issue and/or create a pull request.

Latest podspec

{
    "name": "SafeAreaInputAccessoryViewWrapperView",
    "version": "1.0.1",
    "screenshots": "https://user-images.githubusercontent.com/2835199/31238567-5c96c3f2-a9c8-11e7-86f5-170ebc372cdc.png",
    "summary": "SafeAreaInputAccessoryViewWrapperView provides a way to wrap custom inputAccessoryView views to respect bottom safe area layouts.",
    "description": "SafeAreaInputAccessoryViewWrapperView is useful for wrapping a view to be used as an inputAccessoryView. Without this, setting the view as an inputAccessoryView will ignore safe area layouts. For example, the Home screen indicator on iPhone X will battle for the same spot. This class ensures that the view respects safe area layouts and does not cover up system UI elements such as the Home screen indicator on iPhone X.",
    "homepage": "https://github.com/StockX/SafeAreaInputAccessoryViewWrapperView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jeff Burt": "[email protected]"
    },
    "source": {
        "git": "https://github.com/StockX/SafeAreaInputAccessoryViewWrapperView.git",
        "tag": "1.0.1"
    },
    "social_media_url": "https://twitter.com/jeffburtjr",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "SafeAreaInputAccessoryViewWrapperView/Classes/**/*"
}

Pin It on Pinterest

Share This