问题描述
我有一个UIScrollView,我正在调用scrollRectToVisible:animated:YES就可以了。
我想设置动画的速度。可以这样做吗?
I have a UIScrollView and I'm calling scrollRectToVisible:animated:YES on it.I would like to set the speed at which it is animated. Can that be done?
推荐答案
我最终找到了解决方案。在我的例子中,滚动在启动后以编程方式进行动画制作,以模仿老虎机(具有3个水平UIScrollViews)。正在使用scrollRectToVisible:animated:method。
I ended up finding a solution. In my case, the scrolling was animated programmatically after launch, to mimic a slot machine (with 3 horizontal UIScrollViews). Was doing this with the scrollRectToVisible:animated: method.
我必须使用UIView的beginAnimation设置自定义速度:
I got to set a custom speed using UIView's beginAnimation:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:(abs(rMid-pMid)*0.3)];
scrollMid.contentOffset = CGPointMake(rMid*320, 0);
[UIView commitAnimations];
AnimationDuration取决于滚动条在每个绘图之间移动的距离。
AnimationDuration depends on the distance the scroller has to move between each "drawing".
这篇关于UIScrollView以自定义速度scrollRectToVisible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!