我需要使用 UIViewAnimationOptionTransitionCurlUp 动画重新加载(更新)self.view。在视觉上,旧视图以卷曲效果进行动画处理,并且在其后呈现新的更新视图。我找不到比创建当前视图的屏幕截图更好的方法,将其放在最上面,然后应用动画将其卷起并删除。然后在旧视图卷起后,更新的视图元素会很好地呈现。
但是,卷曲不起作用。过渡变得淡出而不是卷曲。怎么了?代码如下。
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIView* screenView = [[UIView alloc] initWithFrame:self.view.frame];
screenView.tag = TAG_SCREENSHOT_VIEW;
screenView.backgroundColor = [UIColor colorWithPatternImage:screenshot];
[self.view addSubview:screenView];
[screenView.superview bringSubviewToFront:screenView];
[UIView transitionWithView:screenView
duration:1.0f
options:UIViewAnimationOptionTransitionCurlUp
animations:^ { screenView.alpha = 0.0f; }
completion:^ (BOOL finished) {
[screenView removeFromSuperview];
}];