CoolDocMan CoolDocMan - 3 months ago 55x
iOS Question

IOS how to animate first cell of UICollectionView to slide in from right

I have a simple UICollectionView "pictureColectionView" set up in my View Controller.
PicturesVC It allows the user to swipe browse pictures in the collectionview.

The client would like me to add animation so that the first picture "slides in" from left to right when the view controller appears. The layout of PictureVC is as follows:

enter image description here

Question is: Where would I add the animation?


I just thought to add this to PicturesVC viewDidAppear and it worked!

int index_start = -1;
int index_finish = 0;
CGFloat dx_start = index_start*960;
CGFloat dx_finish =index_finish*960;

[self.collectionView setContentOffset:CGPointMake(dx_start, 0) animated:animated];

[UIView animateWithDuration:0.67 animations:
     // Animate the views on and off the screen. This will appear to slide.
     [self.collectionView setContentOffset:CGPointMake(dx_finish, 0) animated:animated];

 completion:^(BOOL finished)
     if (finished)