How to add animation while changing the hidden mode of a uiview?

Sanchit Paurush picture Sanchit Paurush · May 30, 2011 · Viewed 58.4k times · Source

I want to add animation to a view while changing its hidden mode i.e

my_view.hidden=YES;

I have added a button in navigationbar. When we click on it the new view is set to be unhide. It draws at the upper of the navigation table.

Answer

Jeremy W. Sherman picture Jeremy W. Sherman · May 30, 2011

Animate the view's opacity from 100% to 0%. Have the animation completion callback set the view to be hidden. You might also want to reset the opacity back to 100% during the callback, so the view will display fully opaque when you unhide it.

yourView.alpha = 0.0 //for zero opacity
yourView.alpha = 1.0 //for 100% opacity