监听键盘的状态
//键盘将要出现的时候
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(QiuTanTiYuDidClickKeyboard:) name:UIKeyboardWillShowNotification object:nil];
//键盘将要消失的时候
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(QiuTanTiYuDidKeyboadrDisappear:) name:UIKeyboardWillHideNotification object:nil];
对监听到状态的改变,进行改变被遮挡控件的frame
-(void)QiuTanTiYuDidClickKeyboard:(NSNotification *)sender{
CGRect keyboardRect = [sender.userInfo[@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];
[self.QiuTanTiYuBottomView mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-keyboardRect.size.height);
}];
}
-(void)QiuTanTiYuDidKeyboadrDisappear:(NSNotification *)sender{
[self.QiuTanTiYuBottomView mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-XFoot);
}];
}
网友评论