代码:
UIView *superView = [self.view superview];
CATransition *animation = [CATransition animation];
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.type = kCATransitionFade;
animation.subtype = kCATransitionFromTop;
[root.view removeFromSuperview];
[self.view removeFromSuperview];
[superView.layer addAnimation:animation forKey:@"removeContentAnimation"];
self.view和root.view被添加到“superView”
中当我提交此动画时,发生错误的可能性很小 - 两个视图都从superView中删除并立即返回。在这快速变化之后,它正常消失。
答案 0 :(得分:0)
这是一个简短的提示:
- (IBAction)hideView:(id)sender
{
[UIView animateWithDuration:1.0
delay: 0.0
options: UIViewAnimationOptionCurveEaseIn
animations:^{
viewToHide.alpha = 0.0;
}
completion:^(BOOL finished){
[viewToHide removeFromSuperView];
}];
}