获取键盘升起后的高度

//监听键盘事件

    NSNotificationCenter *center=[NSNotificationCenter defaultCenter];

    [center addObserver:self selector:@selector(keyboard:) name:UIKeyboardWillChangeFrameNotification object:nil];

#pragma mark 代理方法

- (void)keyboard : (NSNotification *) noteInfo{

    //获取键盘的高度

    CGRect rect=[noteInfo.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

   

    if (JWScreemSize.height <= 568) {

       //设置页面升高的高度

        self.view.transform=CGAffineTransformMakeTranslation(0, rect.origin.y-JWScreemSize.height);

    }

}

猜你喜欢

转载自my.oschina.net/u/2287505/blog/1632289