UIKeyboard Height 구하기.
NotificationCenter.default.addObserver(self, selector:#selector(keyboardWillShowing(notification:)),
name: Notification.Name.UIKeyboardWillShow, object: nil);
viewdidload 나 원하는곳에 UIkeyboardwillshow 일때 수행할 메서드를 노티피케이션센터에 등록해준다. 뭐 UIkeyboardwillHide도 있고 상황에따라 변경해서쓰시면된다.
func keyboardWillShowing(notification:NSNotification){
let userInfo:NSDictionary = notification.userInfo! as NSDictionary;
let keyboardFrame:NSValue = userInfo.value(forKey: UIKeyboardFrameEndUserInfoKey) as! NSValue
let keyboardRectangle = keyboardFrame.cgRectValue;
let keyboardHeight = keyboardRectangle.size.height;
print(keyboardHeight);
}
키보드정보는 noti 객체에 담겨서온다. 여기서 프레임값을뽑아내면 끝!
'swift 개발' 카테고리의 다른 글
[ swift ] 카카오스토리 공유하기. (0) | 2017.07.10 |
---|---|
[swift] dynamic tableview cell height, uitableview 다른크기의 셀높이 지정하기. (0) | 2017.07.05 |
[swift] UIDatePicker 을 이용한 시작시간 종료시간 (0) | 2017.05.30 |
[swift] 다음 지도 api 사용하기 (0) | 2017.05.26 |
[swift] 네이버 로그인 연동 (0) | 2017.05.18 |
WRITTEN BY
- arcjeen
ios 관련문의 slimforce@naver.com
,