diff --git a/content/notes/wwdc21/10259.md b/content/notes/wwdc21/10259.md index 0e087cf6..1dceec81 100644 --- a/content/notes/wwdc21/10259.md +++ b/content/notes/wwdc21/10259.md @@ -4,7 +4,7 @@ contributors: trav-ma ## UIKeyboardLayoutGuide -Old way of listening for keyboard notifications and adjusting your layout +Here is the old way of listening for keyboard notifications and adjusting your layout: ```swift //... @@ -44,7 +44,7 @@ Old way of listening for keyboard notifications and adjusting your layout } ``` -New in iOS15. Using UIKeyboardLayoutGuide: +New in iOS15. Here is the suggested new way using UIKeyboardLayoutGuide: ```swift view.keyboardLayoutGuide.topAnchor.constraint( @@ -56,7 +56,7 @@ view.keyboardLayoutGuide.topAnchor.constraint( - Use view.keyboardLayoutGuide - For most common use cases, simply update to use .topAnchor - Matches keyboard animations like bring up and dismiss -- Follows height changes when keyboard height adapts for different cases +- Follows height changes as the keyboard can be taller or shorter based on content (showing emojis, etc) - When the keyboard is undocked the guide will drop to the bottom of the screen and be the width of your window - Anything you've tied to the top anchor will follow - It accounts for safe-area insets @@ -64,7 +64,7 @@ view.keyboardLayoutGuide.topAnchor.constraint( ### Why did Apple create a new custom layout guide vs a generic layout guide? -Answer: giving the developer more control of how their layout responds to keyboards +Answer: giving the developer more control over how their layout responds to keyboards - You have the ability to fully follow the keyboard in all its incarnations, if you so choose, by using a new property: `.followsUndockedKeyboard`. - If you set it to true, the guide will follow the keyboard when it's undocked or floating, giving you a lot of control over how your layout responds to wherever the keyboard may be. @@ -73,9 +73,11 @@ Answer: giving the developer more control of how their layout responds to keyboa ## UITrackingLayoutGuide +`UIKeyboardLayoutGuide` is a subclass of the new `UITrackingLayoutGuide` + - Tracks the constraints you want to change when it moves around the screen. - You can give it an array of constraints that activate when near a specific edge, and deactivate when leaving it -- You can give it an array that activates when specifically awayFrom an edge, and deactivates when near it. +- You can give it an array that activates when specifically away from an edge, and deactivates when near it. ### Example Code