Nathan Fiscaletti

$ composer search nafisc/


Locking a view to the top of the keyboard in iOS

Published Mar 21, 2019

Recently I’ve come across the issue where I need to lock a view to the top of the keyboard when it is displayed in an iOS application.

This was doable with a small extension to UIView, how ever it didn’t offer a lot in the way of customization without adding a decent chunk of code.

So, I set to work on KeyboardLock, a simple module for iOS apps that will do most of the work for you.


KeyboardLock is available through CocoaPods. To install it, simply add the following line to your Podfile:

$ pod 'KeyboardLock'


Implementing a keyboard lock is as simple as the following

    withView: containerView,
    andLockType: .BottomConstraint

See the GitHub Repository