键盘弹出 使界面上移

   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChange:) name:UIKeyboardWillChangeFrameNotification object:nil]; /** * 键盘发生改变执行 */
- (void)keyboardWillChange:(NSNotification *)note { NSLog(@"%@", note.userInfo); NSDictionary *userInfo = note.userInfo; CGFloat duration = [userInfo[@"UIKeyboardAnimationDurationUserInfoKey"] doubleValue]; CGRect keyFrame = [userInfo[@"UIKeyboardFrameEndUserInfoKey"] CGRectValue]; CGFloat moveY = keyFrame.origin.y - self.view.frame.size.height; [UIView animateWithDuration:duration animations:^{ self.view.transform = CGAffineTransformMakeTranslation(0, moveY); }]; }

 

你可能感兴趣的:(键盘弹出 使界面上移)