IOS动态获取键盘高度

释放双眼,带上耳机,听听看~!
    //增加监听,当键盘出现或改变时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
//增加监听,当键退出时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
#pragma mark - notif
- (void)keyboardWillShow:(NSNotification *)notification
{
NSDictionary* info = [notification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:[info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]
delay:0
options:([info[UIKeyboardAnimationCurveUserInfoKey] integerValue]<<16)
animations:^{
_tableFooterLayout.constant = 60 + kbSize.height;
}
completion:nil];
}
- (void)keyboardWillHide:(NSNotification *)notification {
NSDictionary* info = [notification userInfo];
[UIView animateWithDuration:[info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]
delay:0
options:([info[UIKeyboardAnimationCurveUserInfoKey] integerValue]<<16)
animations:^{
_tableFooterLayout.constant = 60;
}
completion:nil];
}

人已赞赏
iOS文章

IOS CollectionView拖拽移动

2020-4-29 13:48:01

iOS文章

ios view的形变

2020-4-29 15:03:04

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索