//此前要遵循UITextFieldDelegate代理。并且设置该文本框为当前控制器的代理
//开始编辑的时候让整个view的高度网上移动
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[UIView animateWithDuration:0.3f animations:^{
CGRect curframe = self.view.frame; //不能直接修改frame的y值。需要先将其取出,然后再赋值回去
curframe.origin.y -= ;
self.view.frame = curframe;
}];
}
//当结束编辑的时候,又将整个view退回到原来的位置
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[UIView animateWithDuration:0.3f animations:^{
CGRect curframe = self.view.frame;
curframe.origin.y += ;
self.view.frame = curframe;
}];
}