keyboardFrameEndUserInfoKey
A user info key to retrieve the keyboard’s frame at the end of its animation.
Declaration
nonisolated class let keyboardFrameEndUserInfoKey: StringDiscussion
The value for this key is an NSValue object that contains a CGRect for identifying the frame rectangle of the keyboard (in the screen’s coordinate space) after animating the keyboard. The frame rectangle reflects the current orientation of the device.
The keyboard’s frame uses the screen’s coordinate space, which is different than the coordinate space of your views. Although they might sometimes match, such as when your app is full screen, they might be different when your app isn’t full screen in Split View, Slide Over, and Stage Manager. This means you need to account for this difference by converting the keyboard’s frame from the screen’s coordinate space to that of your views. The following code example shows how to convert from the screen’s coordinate space to your view’s coordinate space:
The keyboard might overlap only part of your view, so after you convert the frame to your view’s coordinate space, get the intersection of the keyboard’s frame and the view or window it overlaps. Getting the intersection allows you to work with only the portion of the keyboard that overlaps your view. You can use this value to offset your views or perform other necessary updates to your UI. The following code example shows how to offset the bottom of your view the appropriate distance in relation to the keyboard’s frame:
See Also
Constants
keyboardAnimationCurveUserInfoKeykeyboardAnimationDurationUserInfoKeykeyboardDidChangeFrameNotificationkeyboardDidHideNotificationkeyboardDidShowNotificationkeyboardFrameBeginUserInfoKeykeyboardIsLocalUserInfoKeykeyboardWillChangeFrameNotificationkeyboardWillHideNotificationkeyboardWillShowNotification