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 以自定义速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

相关文档推荐

Cancel current UIScrollView touch(取消当前 UIScrollView 触摸)
Scale image to fit screen on iPhone rotation(缩放图像以适应 iPhone 旋转时的屏幕)
How to make a screenshot of all the content of a Scrollview?(如何截取 Scrollview 的所有内容?)
Swift iOS Set scrollView constraint below navigation bar programmatically(Swift iOS以编程方式在导航栏下方设置滚动视图约束)
UILabel sizeToFit method not working properly(UILabel sizeToFit 方法无法正常工作)
Get the current UIScrollView scroll values on the iPhone?(获取 iPhone 上当前的 UIScrollView 滚动值?)