码迷,mamicode.com
首页 > 其他好文 > 详细

键盘事件

时间:2018-01-18 20:40:31      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:build   obj   with   server   view   uil   hone   键盘事件   color   

 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 }

 

键盘事件

标签:build   obj   with   server   view   uil   hone   键盘事件   color   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!