动画UISlider顺利 [英] Animate UISlider smoothly
本文介绍了动画UISlider顺利的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要对动画的例如UISlider 0.25〜0.75和背部。这应该显示什么是做用户。
i want to animate an UISlider for e.g. 0.25 to 0.75 and back. This should show the user what is to do.
我想这:
[self incrementCounter:[NSNumber numberWithInt:0]];
-(void) incrementCounter:(NSNumber *)i {
[Slider setValue:[i floatValue]/1000];
[self performSelector:@selector(incrementCounter:) withObject:[NSNumber numberWithInt:i.intValue+1] afterDelay:0.001];
}
但那不是那么顺利......我可以用转换为这个?
but thats not so smooth... can i use transitions for this?
[Slider setValue:1 animated:YES];
是快速...
[UIView animateWithDuration:2.0
animations:^{
[Slider setValue:0.2];
}];
[UIView animateWithDuration:2.0
animations:^{
[Slider setValue:0.5];
}];
只是动画第二个...
Just animates the second one...
推荐答案
您需要链动画通过将第二个动画第一完成块:
You need to chain the animations by putting the second animation in the completion block of the first:
-(IBAction)animateSlider:(id)sender {
[UIView animateWithDuration:2 animations:^{
[self.slider setValue:.75];
} completion:^(BOOL finished) {
[UIView animateWithDuration:2 animations:^{
[self.slider setValue:0.25];//or `[self.slider setValue:(.75)-(.5*finished)];` if you want to be safe
}];
}];
}
这篇关于动画UISlider顺利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文