我的 UIViewController 获得了它控制的视图,以完全重建自己,如下所示:
[self.view rebuildYourself:bIsLandscape]; // this line is in the ViewController
然后视图本身包含以下方法:
-(void)rebuildYourself:(BOOL)isLandscape
{
NSArray *viewsToRemove = [self subviews];
for (UIView *v in viewsToRemove) {
[v removeFromSuperview];
}
[self addControls]; // adds lots of views
[self layoutControlsWithOrientation:isLandscape]; // frames the views
}
我想为整个过渡设置动画。我试过这个:
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[self.view rebuildYourself:bIsLandscape];
}
completion:^(BOOL finished){
}];
但是动画忽略了UIViewAnimationOptionTransitionCurlUp的options值,每次都是从左上角流入。
我试过这个:
[UIView beginAnimations:@"kkk" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationDuration:1.0];
[self.view rebuildYourself:bIsLandscape];
[UIView commitAnimations];
但在这种情况下,过渡确实很好地卷曲,但底层视图在过渡完成之前是空白的,然后新视图突然“弹出”到视图中,这破坏了过渡的效果。
谁能告诉我为视图完全重建自身的过渡设置动画的正确/最佳方式?
谢谢