Chris
Chris

Reputation: 5617

Animate a UITableViewCell Out of a UITableView?

Is it possible to animate a UITableViewCell so that when it is selected, it appears to come out of its table, shrink, and appear to disappear into a button on the Navigation Bar?

I feel like this is doable, but I am not sure where to begin.

Any pointers would be very much appreciated.

Upvotes: 0

Views: 168

Answers (1)

AdamPro13
AdamPro13

Reputation: 7400

Assuming your view controller is in a UINavigationController it's possible using UINavigationControllerDelegate.

  1. Set your view controller to be the delegate of your navigation controller (self.navigationcontroller.delegate = self)
  2. Implement the method -navigationController:animationControllerForOperation:fromViewController:toViewController: and return an object that conforms to the UIViewControllerAnimatedTransitioning protocol.
  3. Implement the methods for that protocol. In the method -animateTransition: you will be passed a parameter that conforms to UIViewControllerContextTransitioning. This object will allow you to get a reference to the view controller you're transitioning to & from.
  4. In the same method, you're going to do the animation. It's going to be custom. You will want to take a snapshot of the view you're transitioning to. At this point it's a matter of figuring out the cell's location, creating a view that contains an image of the cell, and performing the necessary animations and transforms.

As with most custom animations, this isn't a trivial thing but this should get you going down the right path. Hope this helps.

Upvotes: 1

Related Questions