I have a subView that I want to toggle between hidden and not hidden by a button. How do I fade in the subview and fade it out? For now it just appears immediately and disappear immediately when I toggle the button.
I am wondering what is the easiest way to do this animation.
Thanks
On iOS 4.0+ Apple recommends you use their new, block-based animation methods. Using these, the code would look something like this:
The properties you are animating go inside the block (the
^{...}part). Blocks are sort of like functions, so you can put multiple lines of code inside of them, if you want to animate multiple properties. For example:If you need to perform an action after the animation is complete, use the
+animateWithDuration:animations:completion:method (which also uses blocks), for example:For more info, check out the UIView Class Reference ‘Animations’ section and ‘Animating Views with Blocks’ section.