-removeFromSuperview
is not an animatable property--it's a method that makes the view disappear. You want to actually instruct the view on how it should animate by manipulating properties on the view such as alpha
or transform
.
To ensure the view is actually removed from the view hierarchy when the animation is complete, you can use +[UIView setAnimationDidStopSelector:]
and +[UIView setAnimationDelegate:]
. If you're only targetting iOS 4 and later, you can use two blocks and have much simpler code:
[UIView animateWithDuration: 1.0
animations: ^ {
/* This code is animated. */
view.alpha = 0.0;
view.transform = CGAffineTransformMakeScale(0.1, 0.1);
}
completion: ^ (BOOL finished) {
/* This code is run after the animation stops. */
[view removeFromSuperview];
}
];