问题描述
我有两个翻转的视图(例如在卡上水平翻转)。 iOS 13已贬值了开始动画代码,我正在尝试找出如何使用[UIView animateWithDuration:delay:options:animations:completion:]
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.ABCard cache:YES];
[self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
我正在尝试执行以下操作,但是动画只是在没有翻转动作的情况下立即切换视图。
[UIView animateWithDuration:1.0 delay:1.0
options: UIViewAnimationCurveEaseInOut | UIViewAnimationTransitionFlipFromLeft
animations:^{
[self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
} completion:^(BOOL finished){
}];
解决方法
exchangeSubviewAtIndex不会更改动画的外观,因此不会产生动画,这就是为什么只看到它翻转的原因。
此答案的结果可能会帮助您找到适当的解决方案:iPhone Flip Animation using UIViewAnimationTransitionFlipFromLeft in landscape mode