UIScrollView以自定义速度scrollRectToVisible [英] UIScrollView scrollRectToVisible at custom speed

查看:98
本文介绍了UIScrollView以自定义速度scrollRectToVisible的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆