Implement the two methods in the KeyboardHelperDelegate:
public func keyboardWillAppear(_ info: KeyboardHelper.KeyboardAppearanceInfo)
public func keyboardWillDisappear(_ info: KeyboardHelper.KeyboardAppearanceInfo)
Both methods take as argument a KeyboardAppearanceInfo object, which is basically a wrapper over the userInfo dictionary of the UIKeyboardWillShowNotification and UIKeyboardWillHideNotification notifications.
One example of implementation for the two delegate methods is:
This library has been deprecated and the repo has been archived.
The code is still here and you can still clone it, however the library will not receive any more updates or support.
KeyboardHelper
A small (but cool) tool for handling UIKeyboard appearing and disappearing in your view controllers.
📦 Installation
Carthage
CocoaPods
🔧 Setup
Implement
KeyboardHelperDelegatein your UIViewController.Add a
KeyboardHelperprivate variable, initialize it and set the delegate.Implement the two methods in the
KeyboardHelperDelegate:Both methods take as argument a
KeyboardAppearanceInfoobject, which is basically a wrapper over theuserInfodictionary of theUIKeyboardWillShowNotificationandUIKeyboardWillHideNotificationnotifications.One example of implementation for the two delegate methods is:
The
KeyboardAppearanceInfoobject has the following properties:beginFrame: aCGRectcorresponding to the value forUIKeyboardFrameBeginUserInfoKeyendFrame: aCGRectcorresponding to the value forUIKeyboardFrameEndUserInfoKeybelongsToCurrentApp: aBoolcorresponding to the value forUIKeyboardIsLocalUserInfoKeyanimationDuration: aDoublecorresponding to the value forUIKeyboardAnimationDurationUserInfoKeyanimationCurve: aUIViewAnimationCurvecorresponding to the value forUIKeyboardAnimationCurveUserInfoKeyanimationOptions: aUIViewAnimationOptionsfrom the value ofUIKeyboardAnimationCurveUserInfoKeyKeyboardAppearanceInfoalso has the convenience methodanimateAlong:completion:, which can be used like this:to get the same effect as the initial
keyboardWillAppear:implementation example above.👥 Credits
Made with ❤️ at Nodes.
📄 License
KeyboardHelper is available under the MIT license. See the LICENSE file for more info.