Simulate UIScrollView Deceleration(模拟 UIScrollView 减速)
问题描述
我有一个 UIPanGestureRecognize
用于更改视图的框架.当手势的状态为 UIGestureRecognizerStateEnded
时,有没有办法模拟 UIScrollView
或 UITableView
的减速?这是我当前的代码:
I have an UIPanGestureRecognize
which I use to change the frame of a view. Is there a way to simulate the deceleration of the UIScrollView
or UITableView
when the gesture's state is UIGestureRecognizerStateEnded
? Here is my current code:
if (panGesture.state == UIGestureRecognizerStateEnded)
{
[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.view.frame = CGRectMake(182, 0, self.view.frame.size.width, self.view.frame.size.height);
}
completion:^(BOOL finished) {
if (finished) {
//Do something
}
}];
}
但这不是一个流畅的滚动.我想要一些能减速直到停止到我设定的点的东西.谢谢
but this is not a smooth scroll. I would like something that decelerates until it stops to the point I've set. Thanks
推荐答案
WWDC 2012 的第 223 场会议,使用滚动视图增强用户体验",介绍了一种使用滚动视图的行为和感觉"来设置滚动视图位置动画的方法不同的视图(滚动视图实际上对用户不可见).
Session 223 at WWDC 2012, "Enhancing User Experience With Scroll Views", covered a method to use a scrollview's behavior and "feel" to animate the position of a different view (without the scrollview ever actually being visible to the user).
会话中显示的方法的好处是您的减速将始终与 UIScrollView 匹配,现在和永远.
The benefit of the method shown in the session is that your deceleration would always match UIScrollView's, now and forever.
https://developer.apple.com/videos/wwdc/2012/?id=223
这篇关于模拟 UIScrollView 减速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:模拟 UIScrollView 减速
基础教程推荐
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01