UIScrollView scrollRectToVisible at custom speed(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 以自定义速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIScrollView scrollRectToVisible 以自定义速度
基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01