I want something similar in purpose to Flipboard slight flipping animation on app start. Flipboard when launched has this slight flipping of up and down to show users unfamiliar with the interface that it is flippable.
I have a UIScrollView I want to animate a bit to show the user that it's scrollable. So I want to scroll to the right a little bit and back. UIScrollView has a setContentOffset:animated:
message without a completion clause. I find that calling it twice results in seemingly no animation. What if I want an animation after animation in succession?
EDIT: Thanks Levi for the answer. And for the record, there is UIViewAnimationOptionAutoreverse
and UIViewAnimationOptionRepeat
that I can use. So this is what I ended up with that works.
CGPoint offset = self.scrollView.contentOffset; CGPoint newOffset = CGPointMake(offset.x+100, offset.y); [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAutoreverse |UIViewAnimationOptionRepeat animations:^{ [UIView setAnimationRepeatCount: 2]; [self.scrollView setContentOffset:newOffset animated: NO]; } completion:^(BOOL finished) { [self.scrollView setContentOffset:offset animated:NO]; }];
For a scrollView, tableView or collectionView if you do something like this:
[self.collectionView setContentOffset:CGPointMake(self.collectionView.contentOffset.x+260.0, self.collectionView.contentOffset.y) animated:YES];
then you'll get back a:
-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
when the scroll finishes.
You do NOT get this callback if the user moves the view.
Two options:
1) Use the -(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
delegate callback
2) Try to put it into an animation block (with ... animated:NO];
), which has the completion part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With