我有一个 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 减速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!