[英]Remove UIVIew from SuperView with Animation
I can animate the addition of a UIView to my app, it looks very pretty so thank you apple.我可以将 UIView 添加到我的应用程序中,它看起来非常漂亮,所以谢谢苹果。
However, how do I animate the removal of this view from the super view?但是,如何为从超级视图中删除此视图设置动画?
I'm using:我在用着:
CATransition *animation = [CATransition animation];
[animation setDuration:1];
[animation setType:kCATransitionReveal];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[myview layer] addAnimation:animation forKey:kCATransitionReveal];
to animate the "in" transition... how do you animate the "out" transition????动画“in”过渡...你如何动画“out”过渡????
Animate your view so it moves offscreen/shrinks/expands/fades, then do the actual removal when the animation ends.为您的视图设置动画,使其移出屏幕/缩小/展开/淡入淡出,然后在 animation 结束时进行实际移除。
You can do this by altering the properties of the view (position/size/offset) between a beginAnimations/commitAnimations block.您可以通过在 beginAnimations/commitAnimations 块之间更改视图的属性(位置/大小/偏移)来做到这一点。 UIKit will then animate these properties over the time specified.
UIKit 将在指定的时间内为这些属性设置动画。
Eg something like;例如类似的东西;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.30f];
view.transform =
CGAffineTransformMakeTranslation(
view.frame.origin.x,
480.0f + (view.frame.size.height/2) // move the whole view offscreen
);
background.alpha = 0; // also fade to transparent
[UIView commitAnimations];
In the animation end notification you can then remove the view.在 animation 结束通知中,您可以删除视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.