Question

I have 2 UIViewControllers with similar UIView components in them. For instance the first UIViewController can have a small UIImageView while the second UIViewController has a large UIImageView.

Using UIView animateWithDuration:animations:

I could do something like

// this is the original size frame
self.imageView.frame = smallFrame;


// somewhere in the code make a big frame and animate it
UIView animateWithDuration:1 animations^ { self.imageView.frame = bigFrame; }

But I would like to animate a UIView component while pushing between View Controllers

firstViewController pushViewController:secondViewController; // this should animate the frame size 
// of the imageView in the first view controller to the frame size of the imageView in the second 
//view contoller 

Similar behavior can be seen in the Facebook app when choosing a photo in the feed or photoalbum. The background becomes dark and the image gets bigger.

I believe that these are 2 separate view controllers such that the animation during push gives the perception of the frame size growing and shrinking. This would facilitate reuse of this gallery view controller.

How can this be achieved for any view?

Was it helpful?

Solution

I believe you would want to look into the UIViewControllerAnimatedTransitioning class.

Here is a link on custom view controller transitions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top