问题描述
我正在尝试为UIToolbar的tintColor属性设置动画,以将其从一个tintColor更改为另一个.
I am trying to animate a UIToolbar's tintColor property, to change it from one tintColor to another.
这是我正在尝试的代码.不幸的是,更改会立即发生,并且不会从绿色变为蓝色.这很奇怪,因为我知道在网络共享或打来电话时,苹果会褪色并且脉冲"工具栏的颜色会变淡.那为什么不起作用呢?
Here is the code I am trying. Unfortunately, the change occurs immediately and does not fade from green to blue. This is strange because I know Apple fades and "pulses" toolbar tint colors when tethering or on a phone call. So why doesn't this work?
// set initial tint color
myBottomToolBar.tintColor = [UIColor colorWithRed:0.15 green:0.95 blue:0.15 alpha:0.6];
//animation stuff
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.95];
[UIView setAnimationDelegate:self];
//thing to animate
myBottomToolBar.tintColor = [UIColor colorWithRed:0.15 green:0.35 blue:0.45 alpha:0.6];
//animation stuff
[UIView commitAnimations];
推荐答案
无法通过公共API设置动画的颜色.您可以通过手动更改计时器的颜色来解决此问题.您将必须插入中间颜色级别.
The tint color in not animatable through public APIs. You can work around this by manually changing the tint color on a timer. You would have to interpolate the intermediate color levels.
这篇关于我可以淡入淡出/为UIToolbar的tintColor设置动画吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!