【发布时间】:2012-06-13 19:17:09
【问题描述】:
当您实际滚动到下一页时,我正在尝试重现启用分页的滚动视图的流畅动画。似乎是UIViewAnimationCurveEaseInOut,但我需要有一个“下一页”按钮并以编程方式触发滚动。
这是我的代码:
-(void) scrollToPage:(int)page
{
UIScrollView *scrollView = contentView;
CGPoint offset = CGPointMake(scrollView.bounds.size.width * page, scrollView.contentOffset.y);
[scrollView setContentOffset:offset animated: YES];
[self pageControlUpdate];
}
-(void) scrollToNextPage
{
[self scrollToPage:(pageControl.currentPage + 1)];
}
我无法重现UIViewAnimationCurveEaseInOut的流畅度,
或者setContentOffset,或者scrollRectToVisible...
它以丑陋的线性动画进入下一页
我什至尝试手动对其进行动画处理:
[UIView animateWithDuration:.5 delay:0 options:UIViewAnimationCurveEaseInOut animations:^{
scrollView.contentOffset = offset;
} completion:^(BOOL finished) { } ];
我哪里错了?
【问题讨论】:
-
我发现了这个:developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/…,这证实了我所看到的:
The setContentOffset:animated: method scrolls the content to the specified content offset. If the animated parameter is YES, the scrolling will animate from the current position to the specified position at a constant rate. -
参数。没人知道吗?
-
好吧,如果
UIViewAnimationCurveEaseInOut不起作用,它可能是不同的动画曲线。 Apple 很可能会为此动画使用自定义曲线。使用CAPropertyAnimation,您可以以CAMediaTimingFunction的形式定义自己的自定义曲线。可能值得尝试使用不同的控制点。 -
我无法让它工作。你知道使用 CAPropertyAnimation 的教程或代码示例吗?
标签: iphone ios ipad uiscrollview