Search code examples
iosuitableviewuser-interfacecore-animation

How do I make a button slide to reveal like the UITableView delete confirmation button?


I would like to re-create the animation of the delete confirmation button that Apple uses in the default implementation of UITableView. I want to create this button and animation in my own custom view area, but haven't been successful in finding a proper view transition or animation. Here is a picture of the reveal animation half way through:

enter image description here

And here is a picture of the animation after it has finished:

enter image description here

These are screenshots from a YouTube video that shows how the button animation is supposed to look.

Thanks!


Solution

  • Basically, 1) Put a button inside a view of the same size as the button, with the autoresizing masks of the button set to force it to not shrink when the view changes size, and have a left flexible margin. 2) Animate the view's frame to change from 0 width to full width while moving from x origin to (x - view width) origin.

    As the view grows the button will be revealed. The view should have clipToBounds set to yes.