首页 > 其他 > 详细

键盘事件

时间:2018-01-18 20:21:00      阅读:216      评论:0      收藏:0      [点我收藏+]
 1 - (void)buildNotification {
 2     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowWithNotification:) name:UIKeyboardWillShowNotification object:nil];
 3     
 4     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHideWithNotification:) name:UIKeyboardWillHideNotification object:nil];
 5  }
 6 
 7 - (void)keyboardWillShowWithNotification:(NSNotification *)notification {
 8     CGRect rect = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
 9     CGFloat height = rect.size.height - (kDevice_iPhoneX ? kFloatBottomDangerHeight : 0);
10 
11     [UIView animateWithDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
12         _inputTextView.transform = CGAffineTransformMakeTranslation(0, - height);
13     }];
14 }
15 
16 - (void)keyboardWillHideWithNotification:(NSNotification *)notification {
17     [UIView animateWithDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{
18         _inputTextView.transform = CGAffineTransformIdentity;
19     }];
20 }

 

键盘事件

原文:https://www.cnblogs.com/lz465350/p/8312549.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!