键盘上移
- (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); }]; }