OGeek|极客世界-中国程序员成长平台

标题: ios - 在同一个 ViewController 上转换 View [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 21:49
标题: ios - 在同一个 ViewController 上转换 View

我正在尝试在同一个 ViewController 上翻转过渡,我有一个用于触发过渡的按钮。当我通过翻转转换按下按钮时,我想更改主题颜色。

我使用了这个代码部分:

- (IBAction)changeThemeButtonTappedid)sender
{

int tempThemeColor = [[NSUserDefaults standardUserDefaults]integerForKey"themeColor"];


if (tempThemeColor == 10) {

    [self loadTheme];
    [UIView transitionFromView:self.view

                        toView:self.view

                      duration:1.0

                       options:UIViewAnimationOptionTransitionFlipFromLeft

                    completion:^(BOOL finished) {
                        NSLog(@"finished");

    }];

}else{

    [self loadTheme];
    [UIView transitionFromView:self.view

                        toView:self.view

                      duration:1.0

                       options:UIViewAnimationOptionTransitionFlipFromRight

                    completion:^(BOOL finished) {
                        NSLog(@"finished");

    }];

}  
}

当我按下按钮时, View 变为黑色。有什么办法吗?我的错误是什么? 感谢您的回答和关注。



Best Answer-推荐答案


我找到了我的问题的答案。

if (tempThemeColor == 10) {

    [self loadTheme];

    [UIView transitionWithView:self.view
                      duration:1.0
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{

                    } completion:^(BOOL finished) {

                    }];

}else{

    [self loadTheme]; 
    [UIView transitionWithView:self.view
                      duration:1.0
                       options:UIViewAnimationOptionTransitionFlipFromRight
                    animations:^{

                    } completion:^(BOOL finished) {

                    }];

}

关于ios - 在同一个 ViewController 上转换 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23285651/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4