Animate while UIScrollView bounces
I want to do a little animation every time the UIScrollView bounces, to be exact, I want a button to move a little bit to the left and then back to it's original position. I use the scrollViewDidScroll
method and check if the scrollView's contentOffset is higher than the actual content height and then call the animation. The problem is that the ani开发者_如何学Gomation is called multiple times during the bounce if I do it like that. Is there a way to only call it once?
Have an ivar or property named something like animationActive that will keep track of animation. When you start it, set animationActive = YES;
and when animation completes, set animationActive = NO;
. And of course, before you start animation, check if (animationActive == YES)
.
精彩评论