[英]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.