我通过以下方式为子视图的外观设置了动画:
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionReveal;
[webView.layer addAnimation:transition forKey:nil];
[self.view addSubview:webView];
但现在我要删除我的subView。如何添加动画来执行此操作?像其他CATransition一样?什么时候加?在addSubview之前或之后?
答案 0 :(得分:22)
您可以先在animationEndListener
来电removeFromSuperView
[UIView animateWithDuration:0.5
delay:1.0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
yourView.alpha = 0;
}completion:^(BOOL finished){
[yourView removeFromSuperview];
}];