gpt4 book ai didi

iphone - 为 UIView 更改设置动画,其中 UIView 已完全重建

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:15:14 25 4
gpt4 key购买 nike

我的 UIViewController 得到它正在控制的 View ,用这样的东西完全重建自己:

[self.view rebuildYourself:bIsLandscape]; // this line is in the ViewController

然后 View 本身包含以下方法:

-(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];

但在这种情况下,过渡确实很好地卷起,但在过渡完成之前,底层 View 是空白的,然后新 View 突然“弹出”到 View 中,这破坏了过渡的效果。

谁能告诉我在 View 完全重建自身的情况下动画过渡的正确/最佳方法?

谢谢

最佳答案

制作两个 View 并将旧 View 置于新的重建 View 之上。然后“卷起”旧 View ,以便显示新 View 并从内存中删除旧 View 。

关于iphone - 为 UIView 更改设置动画,其中 UIView 已完全重建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11032437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com