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 减速
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
