UI中实现点击输入框时整个屏幕往上升,解决部分界面被遮盖问题
当点击输入框准备编辑时调用 animateKeyframesWithDuration 方法
// start time and duration are values between 0.0 and 1.0 specifying time and duration relative to the overall time of the keyframe animation
//准备开始编辑时屏幕上升
- (void)textFieldDidBeginEditing:(UITextField *)textField{
[UIView animateKeyframesWithDuration:0.25 delay:0 options:0 animations:^{
self.view.frame = CGRectMake(0, -50, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
} completion:nil];
}
//准备结束编辑时屏幕下降
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField{
[UIView animateKeyframesWithDuration:0.25 delay:0 options:0 animations:^{
self.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
} completion:nil];
return YES;
}