Skip to content
⌨️ Apple's missing KeyboardLayoutGuide
Branch: master
Clone or download
Latest commit eb08739 Jul 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Jul 8, 2019
Images Updates gif Dec 4, 2017
KeyboardLayoutGuide Bumps to 1.4.2 Jul 11, 2019
KeyboardLayoutGuideExample Bumps to 1.4.2 Jul 11, 2019
.gitignore Adds ignoring of DS_Store files on macOS Apr 15, 2019
Keyboard+LayoutGuide.podspec Bumps to 1.4.2 Jul 11, 2019 Bumps to 1.4.2 Jul 11, 2019
LICENSE Initial commit Nov 14, 2017
Package.swift Add SPM intergration Jul 5, 2019 Bumps to 1.4.2 Jul 11, 2019

⌨️ KeyboardLayoutGuide

Apple's missing KeyboardLayoutGuide

Language: Swift 5 Platform: iOS 9+ SPM compatible Carthage compatible CocoaPods compatible Build Status codebeat badge License: MIT GitHub tag

  • No Subclassing / Protocol inheritance / obscure overrides
  • No more keyboard notification handling
  • UIKit Friendly
  • Takes safeArea into account
  • Only animates if view is fully on screen

How to use it

Simply constrain your views to the KeyboardLayoutGuide's top anchor the way you would do natively:

override func viewDidLoad() {

    // Pin your button to the keyboard
    button.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor).isActive = true

Bonus: if you're using Stevia, this gets even more concise \o/

button.Bottom == view.keyboardLayoutGuide.Top

If you add your view in Interface Builder, don't forget to enable the "Remove at build time" checkbox for the bottom constraint:

Safe Area

By default, KeyboardLayoutGuide will align your item with the bottom safe area. This is a behaviour that can be opt out with the usesSafeArea property.

// Opt out of safe area if needed.
view.keyboardLayoutGuide.usesSafeArea = false



To install KeyboardLayoutGuide via CocoaPods, add the following line to your Podfile:

target 'MyAppName' do
  pod 'Keyboard+LayoutGuide'


To install KeyboardLayoutGuide via Carthage, add the following line to your Cartfile:

github "freshos/KeyboardLayoutGuide"

Swift Package Manager

To integrate KeyboardLayoutGuide via SPM into your Xcode 11 project specify it in Project > Swift Packages:


Just add Keyboard+LayoutGuide.swift to your Xcode project.


KeyboardLayoutGuide is available under the MIT license. See the LICENSE file for more info.

You can’t perform that action at this time.