我有一个 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 个水平 UIScrollView).正在使用 scrollRectToVisible:animated: 方法执行此操作.
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 以自定义速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!