Skip to content

Commit e398c68

Browse files
committed
Update ReadMe with keyboardLayout information
1 parent b320b66 commit e398c68

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ newView.layout.applyConstraint { view in
4040
}
4141
```
4242

43+
## Keyboard Layout Guide
44+
45+
The `KeyboardLayoutGuide` allows you to align your views relative to the keyboard in a native way, without observing notifications or calculating keyboard heights manually.
46+
47+
### Basic usage
48+
49+
```swift
50+
override func viewDidLoad() {
51+
super.viewDidLoad()
52+
53+
// Pin your button to the keyboard
54+
button.layout.applyConstraint { button in
55+
button.bottomAnchor(equalTo: view.keyboardLayoutGuide.topAnchor)
56+
}
57+
}
58+
```
59+
60+
In the example above, the button will always be anchored to the top of the keyboard, automatically adjusting when the keyboard appears or disappears.
61+
62+
### Safe Area behavior
63+
64+
By default, the `KeyboardLayoutGuide` aligns your view with the **bottom safe area** when available (iOS 11.0, tvOS 11.0, macOS 11.0 and later).
65+
On earlier versions, it falls back to the view’s `bottomAnchor`.
66+
4367
## Requirements
4468

4569
- iOS 9.0+ / tvOS 9.0+ / macOS 10.11+

0 commit comments

Comments
 (0)