UIKit - NotificationCenter 키보드 height 구하기
NotificationCenter를 통해 키보드가 올라왔을때, 혹은 내려갈때 시점을 처리할 수 있음.
이때 키보드의 height를 구하는 방법은 아래와 같음.
1
2
3
4
5
6
7
@objc func keyboardWillShow(notification: NSNotification){
if let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue{
let keyboardRectangle = keyboardFrame.cgRectValue
let keyboardHeight = keyboardRectangle.height
}
}
This post is licensed under CC BY 4.0 by the author.