TKKeyboardControl adds keyboard awareness and scrolling dismissal (like iMessages app) to any view with only 1 line of code for Swift4 and it supports SafeArea. This library is inspired by DAKeyboardControl.
- Keyboard closing without UIScrollView
- Support
Swift4
- Support
Safe Area
TKKeyboardControl is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TKKeyboardControl', :git => 'https://github.com/cokaholic/TKKeyboardControl.git', :tag => '2.0.0'
Add the TKKeyboardControl directory to your project.
Example project included (./Example)
view.addKeyboardPanning(frameBasedActionHandler: { keyboardFrameInView, firstResponder, opening, closing in
// Move interface objects accordingly
// Animation block is handled for you
})
// Make sure to call self.view.removeKeyboardControl before the view is released.
// (It's the balancing call)
view.addKeyboardPanning(constraintBasedActionHandler: { keyboardFrameInView, firstResponder, opening, closing in
// Move interface objects accordingly
// Animation block is handled for you
})
// Make sure to call self.view.removeKeyboardControl before the view is released.
// (It's the balancing call)
view.addKeyboardNonpanning(frameBasedActionHandler: { keyboardFrameInView, firstResponder, opening, closing in
// Move interface objects accordingly
// Animation block is handled for you
})
// Make sure to call self.view.removeKeyboardControl before the view is released.
// (It's the balancing call)
view.addKeyboardNonpanning(constraintBasedActionHandler: { keyboardFrameInView, firstResponder, opening, closing in
// Move interface objects accordingly
// Animation block is handled for you
})
// Make sure to call self.view.removeKeyboardControl before the view is released.
// (It's the balancing call)
The keyboardTriggerOffset
property allows you to choose at what point the user's finger "engages" the keyboard.
view.keyboardTriggerOffset = 44.0; // Input view frame height
view.addKeyboardNonpanning(frameBasedActionHandler: { keyboardFrameInView, firstResponder, opening, closing in
// Move interface objects accordingly
// Animation block is handled for you
})
// Make sure to call self.view.removeKeyboardControl before the view is released.
// (It's the balancing call)
view.hideKeyboard()
view.removeKeyboardControl()
TKKeyboardControl
was made with ARC enabled by default.
- Xcode 8.0 or greater
- iOS9.0 or greater
- Swift4.0 or greater
Keisuke Tatsumi, nietzsche.god.is.dead@gmail.com
TKKeyboardControl is available under the MIT license.
Copyright (c) 2018 Keisuke Tatsumi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.