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 减速


- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01