解决方法
好.以下是动画要求的示例代码.
- (void) showView { [self.view addSubview:yourDatePickerView]; yourDatePickerView.frame = CGRectMake(0,-250,320,50); [UIView animateWithDuration:1.0 animations:^{ yourDatePickerView.frame = CGRectMake(0,152,260); }]; }
以下是隐藏DatePickerView的方法
- (void) hideView { [UIView animateWithDuration:0.5 animations:^{ yourDatePickerView.frame = CGRectMake(0,50); } completion:^(BOOL finished) { [yourDatePickerView removeFromSuperview]; }]; } - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { if(textField == yourDateTextField) { [self showView]; return NO; // preventing keyboard from showing } return YES; } - (void)textFieldDidEndEditing:(UITextField *)textField { if(textField == yourDateTextField) { [self hideView]; } }
这就是你所需要的一切.