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

键盘上移

时间:2015-11-06 00:16:57      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

- (void)keyboardFrameChange:(NSNotification *)info{
    
   
 1.获取键盘最后的y值
    NSDictionary *keyBoardDict =   info.userInfo;
    CGRect keyBoardFrame = [keyBoardDict[UIKeyboardFrameEndUserInfoKey]CGRectValue];
//    2.设置view的移动的范围
    CGFloat viewH = self.view.frame.size.height;
    CGFloat keyBoardTy = keyBoardFrame.origin.y - viewH;
    CGFloat duration = [keyBoardDict[UIKeyboardAnimationDurationUserInfoKey]doubleValue];
    [UIView animateWithDuration:duration animations:^{
         self.view.transform = CGAffineTransformMakeTranslation(0, keyBoardTy);
    }];
   
    
}

 

键盘上移

标签:

原文地址:http://www.cnblogs.com/gp886/p/4941240.html

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