0

I have a textfield which has a UIDatePicker instead of a keyboard. I also made a toolbar not connected with the datePicker but that just appears when the textfield is tapped. The problem is the animations. The datePicker slides up nicely, but the toolbar just appears before the animation of the datePicker is done. This makes the whole thing look horrible. How would I set the animation to match the datePickers? I have no experience with animations and none of the other posts did any good for me.


EDIT

Based on Tareks answer I was able to set the animation to slide up by doing the following.

First, Setting the toolbar to bottom of screen

pickerBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 480, 320, 44)];

Seconds, Changing the location of the toolbar in the animation

[UIView animateWithDuration:.4 animations:^(void) {

    CGRect rect = CGRectMake(0, 224-46, 320, 44);

    [pickerBar setFrame:rect];
4

2 回答 2

3

出于这个原因,您可以使用 inputAccessoryView 。

textField.inputAccessoryView = [[UIToolbar alloc] init...
于 2013-08-07T13:31:39.317 回答
2

您可以使用下面的代码来显示您的工具栏:

[UIView animateWithDuration:2.0 animations:^(void) {
    toolBar.alpha = 1;
}];

编辑

toolBar.alpha应该是 0。

对于滑动: 它会是这样的:

[UIView animateWithDuration:2 animations:^{
     int newY = yVal; // you can play with this newY.
     CGRect frame = toolBar.frame;
     frame.origin.y = newY;
     toolBar.frame  = frame;
}];
于 2013-08-07T13:31:55.157 回答