首页 > 其他 > 详细

键盘的弹出和收回

时间:2016-04-11 20:21:38      阅读:196      评论:0      收藏:0      [点我收藏+]

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardFrameChange:) name:UIKeyboardWillChangeFrameNotification object:nil];

 #pragma mark 通知的方法

- (void)keyBoardFrameChange:(NSNotification *)userInfo

{

    NSLog(@"userInfo == %@",userInfo.userInfo);

    

    // 取得键盘的Y值

    CGRect rectValue = [userInfo.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

    CGFloat keyBoardY = rectValue.origin.y;

    CGFloat keyBoardTransform = keyBoardY - self.view.frame.size.height;

    self.view.transform = CGAffineTransformMakeTranslation(0, keyBoardTransform);

}

键盘的弹出和收回

原文:http://www.cnblogs.com/fantasy3588/p/5379703.html

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