UIView Animaton 重置为开始
我正在尝试运行动画,以便滚动视图的 contentoffset 不断向下滚动。
但是,每次重复后,它都会从原始位置开始动画,并且不会继续。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatCount: 100];
CGPoint contentOffset = scrollView.contentOffset;
contentOffset.y += 50;
scrollView.contentOffset = contentOffset;
scrollView.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
有什么想法吗?
I'm attempting to run an animation so that the scrollview's contentoffset gets continually scrolling down.
However, after each repeat, it will animate from the original position and it is not progressing.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatCount: 100];
CGPoint contentOffset = scrollView.contentOffset;
contentOffset.y += 50;
scrollView.contentOffset = contentOffset;
scrollView.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您为什么尝试手动滚动视图?不会用这个方法吗
?
无论如何,我相信您的动画未按预期工作的原因是因为您设置了重复计数,而不是每次都实际重新渲染动画。如果您想解决此问题,可以通过创建包装动画并通过上下文指针传递参数的方法,在动画回调中再次设置动画。
然后在你的代码中,只需调用
Why are you attempting to manually scroll the view? Can't you use the method
?
Regardless, I believe the reason your animation isn't working as you expect is because you're setting a repeat count instead of actually re-rendering your animation each time. If you want to work around this problem, you could animate again in the animation callback by creating a method wrapping the animation and passing parameters via the context pointer.
Then in your code, just call