Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从头开始为工具栏设置动画_Ios_Animation_Uitoolbar_Uidatepicker - Fatal编程技术网

Ios 从头开始为工具栏设置动画

Ios 从头开始为工具栏设置动画,ios,animation,uitoolbar,uidatepicker,Ios,Animation,Uitoolbar,Uidatepicker,我有一个textfield,它有一个UIDatePicker而不是一个键盘。我还制作了一个工具栏,它没有连接到日期选择器,但只在点击文本字段时出现。问题在于动画。datePicker很好地向上滑动,但是工具栏在datePicker动画完成之前出现。这让整个事情看起来很可怕。如何将动画设置为与日期选择器相匹配?我没有动画方面的经验,其他帖子也没有对我有任何好处 编辑 根据Tareks的回答,我可以通过执行以下操作将动画设置为向上滑动 首先,将工具栏设置到屏幕底部 pickerBar=[[UITo

我有一个
textfield
,它有一个
UIDatePicker
而不是一个键盘。我还制作了一个
工具栏
,它没有连接到
日期选择器
,但只在点击
文本字段
时出现。问题在于动画。
datePicker
很好地向上滑动,但是
工具栏
datePicker
动画完成之前出现。这让整个事情看起来很可怕。如何将动画设置为与日期选择器相匹配?我没有动画方面的经验,其他帖子也没有对我有任何好处


编辑 根据Tareks的回答,我可以通过执行以下操作将动画设置为向上滑动

首先,将工具栏设置到屏幕底部

pickerBar=[[UIToolbar alloc]initWithFrame:CGRectMake(048032044)]

秒,更改工具栏在动画中的位置

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

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

    [pickerBar setFrame:rect];

因此,您可以使用inputAccessoryView

textField.inputAccessoryView = [[UIToolbar alloc] init...

因此,您可以使用inputAccessoryView

textField.inputAccessoryView = [[UIToolbar alloc] init...

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

[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;
}];

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

[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;
}];

我需要用这个做点别的吗?我不能把这个写进代码里,对吗?很抱歉,当涉及到动画时,我没有任何线索。是的,把它放在你的函数中,它等于工具栏。隐藏=否;我把它放在这行代码之后
[self.view addSubview:pickerBar]
但是什么也没发生第一个toolBar.alpha应该是0,然后当你想显示工具栏时,把上面的代码放在上面.Nvm,我想我现在可以用你的代码自己解决这个问题了。我只需要改变x和y而不是alpha,对吗?我需要用这个做些别的吗?我不能把这个写进代码里,对吗?很抱歉,当涉及到动画时,我没有任何线索。是的,把它放在你的函数中,它等于工具栏。隐藏=否;我把它放在这行代码之后
[self.view addSubview:pickerBar]
但是什么也没发生第一个toolBar.alpha应该是0,然后当你想显示工具栏时,把上面的代码放在上面.Nvm,我想我现在可以用你的代码自己解决这个问题了。我只想改变x和y,而不是alpha,对吗?请展示你尝试过的…到目前为止我没有尝试过任何东西。但是我可以给你看看工具栏和日期选择器请给我看看你试过什么到目前为止我什么都没试过。但是我可以给你看工具栏和datepickerStrange,只需将你的pickerBar分配给它。奇怪的是,只需将你的pickerBar分配给它。