iOS curl up animation to remove uiimageview

2019-04-11 11:38发布

问题:

i'm looking to remove an image from my app with a curl up animation. I've got

[UIView transitionWithView:sender.view.superview duration:1.5
options:UIViewAnimationOptionTransitionCurlUp                           
animations:^ { [sender.view removeFromSuperview]; }
completion:nil];

but this curls the entire page away and looks as though there's a separate page beneath without the image on it.

Instead of a 'transition' to a new page is it possible to curl the image off the page without affecting the rest of the page? Do I need to wrap the imageview in a 'container view' and change transition with view to that?

回答1:

Your view parameter is sender.view.superview which means you want the superview to animate. Just remove the superview part.

Edit: also, for something to animate, it must be animatable property. Removing a view from superview has nothing to do with it's properties. You could animate the view to 0 alpha and on completion of that animation remove it from superview like this:

[UIView transitionWithView:sender.view
                  duration:1.5
                   options:UIViewAnimationOptionTransitionCurlUp                           
                animations:^ { sender.view.alpha = 0; }
                completion:^ { [sender.view removeFromSuperview]; }];