// ✅ Posted immediately prior to a change in the keyboard’s frame.
NotificationCenter.default.addObserver(self, selector: #selector(updateKeyboardFrame(_:)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
@objc
func updateKeyboardFrame(_ notification: Notification) {
// ✅ 바뀐 키보드의 frame.
guard let keyboardEndFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
// ✅ 바뀌기전 키보드의 frame.
guard let keyboardBeginFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue else { return }
// 레이아웃 대응.
}