我有一个UIScrollView
用 coreAnimation 垂直滚动的,如下所示:
- (void) scrollAnimation
{
CGRect bounds = scrollview.bounds;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"bounds"];
animation.duration = 1.0;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.fromValue = [NSValue valueWithCGRect:bounds];
bounds.origin.y += 1000;
animation.toValue = [NSValue valueWithCGRect:bounds];
[scrollview.layer addAnimation:animation forKey:@"bounds"];
scrollview.bounds = bounds;
}
的实际高度scrollView
小于总动画,所以我希望contentOffset
在滚动视图到达其高度末端时将 重置为 0,并无缝地继续动画。
当我尝试在
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y >= 600)
{
[scrollView setContentOffset:CGPointMake(0, 0)];
}
}
在动画期间似乎没有调用该方法。当尝试scrollView
在coreAnimation
. 使用NSTimer
定期检查的方法也被证明是徒劳的。
如何在 a 期间获取contentOffset
(or scrollview.bounds
)coreAnimation
并重置它?
我希望制作动画,scrollView
以便内容(几个UILabels
)在大于内容大小的动画上无缝滚动。