[英]Remove UIVIew from SuperView with Animation
我可以将 UIView 添加到我的应用程序中,它看起来非常漂亮,所以谢谢苹果。
但是,如何为从超级视图中删除此视图设置动画?
我在用着:
CATransition *animation = [CATransition animation];
[animation setDuration:1];
[animation setType:kCATransitionReveal];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[myview layer] addAnimation:animation forKey:kCATransitionReveal];
动画“in”过渡...你如何动画“out”过渡????
为您的视图设置动画,使其移出屏幕/缩小/展开/淡入淡出,然后在 animation 结束时进行实际移除。
您可以通过在 beginAnimations/commitAnimations 块之间更改视图的属性(位置/大小/偏移)来做到这一点。 UIKit 将在指定的时间内为这些属性设置动画。
例如类似的东西;
[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];
在 animation 结束通知中,您可以删除视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.