Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
- minor grammar and spelling updates
Browse files Browse the repository at this point in the history
  • Loading branch information
trav-ma committed Nov 5, 2023
1 parent 4bff6c0 commit 47a8798
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions content/notes/wwdc21/10259.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
//...
Expand Down Expand Up @@ -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(
Expand All @@ -56,15 +56,15 @@ 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


### 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.
Expand All @@ -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

Expand Down

0 comments on commit 47a8798

Please sign in to comment.