键盘的弹出和收回

    [[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);

}

1
原文地址:https://www.cnblogs.com/fantasy3588/p/5379703.html