問題描述
我有一個 UIPanGestureRecognize
用于更改視圖的框架.當手勢的狀態(tài)為 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
}
}];
}
但這不是一個流暢的滾動.我想要一些能減速直到停止到我設(shè)定的點的東西.謝謝
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 場會議,使用滾動視圖增強用戶體驗",介紹了一種使用滾動視圖的行為和感覺"來設(shè)置滾動視圖位置動畫的方法不同的視圖(滾動視圖實際上對用戶不可見).
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 匹配,現(xiàn)在和永遠.
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
這篇關(guān)于模擬 UIScrollView 減速的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!