我正在使用 animateWithDuration 来更改 UISlider 的值:
[UIView animateWithDuration:1.0f
delay:0.0f
options:UIViewAnimationOptionCurveEaseInOut
animations:^{ [myUISlider setValue:10]; }
completion:^(BOOL finished){ }];
问题是,我需要能够在 UISlider更改时显示它的当前值。这甚至可以使用 animateWithDuration 吗?我尝试创建一个 UISlider 子类并覆盖 setValue 以希望在更改滑块时访问滑块的值:
-(void)setValue:(float)newValue
{
[super setValue:newValue];
NSLog(@"The new value is: %f",newValue);
}
但是该代码仅在动画块的最后被调用。以一种非常有意义的方式,因为我真的只调用了一次 setValue。但我希望动画块会以某种方式在其内部机制中一遍又一遍地调用它,但似乎并非如此。
如果 UIView animateWithDuration 在这里是一个死胡同,我想知道是否有更好的方法来用其他东西实现同样的功能?也许我不知道 SDK 的另一个光滑的小块驱动部分允许动画不仅仅是 UIView 参数?