Skip to content

sou1x0/ALSKeyboardLayoutGuide

Repository files navigation

ALSKeyboardLayoutGuide

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Example

Example Codes:

let label = UILabel()
label.textColor = .black
label.text = "I'm above keyboard and inside safe area!"
view.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
label.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
label.bottomAnchor.constraint(lessThanOrEqualTo: view.keyboardLayoutGuide.topAnchor, constant: -8.0).isActive = true
if #available(iOS 11.0, *) {
    label.bottomAnchor.constraint(lessThanOrEqualTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -8.0).isActive = true
} else {
    label.bottomAnchor.constraint(lessThanOrEqualTo: view.bottomAnchor, constant: -8.0).isActive = true
}
let constraint = label.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0.0)
constraint.priority = UILayoutPriority(1)
constraint.isActive = true

Installation

CocoaPods

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

pod 'ALSKeyboardLayoutGuide'

Manually

Drag ALSKeyboard.swift and UIView+KeyboardLayoutGuide.swift files in ALSKeyboardLayoutGuide/Classes directory into your project.

Usage

Use view.keyboardLayoutGuide property to layout with the subviews.

Note: the view's size should be same as the window or the screen. In other words, it's mostly the view of a view controller.

Author

Adelais0

License

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

About

Easily layout views to the keyboard in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published