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

键盘的弹出和收回

时间:2016-04-11 20:24:40      阅读:130      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!