UIScrollView scrollRectToVisible 以自定义速度

UIScrollView scrollRectToVisible at custom speed(UIScrollView scrollRectToVisible 以自定义速度)
本文介绍了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 个水平 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 以自定义速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)
HTTPS request using volley(使用 volley 的 HTTPS 请求)