我想将状态栏的样式设置为:

 [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

如果我直接从AppDelegate进行操作-一切正常,但通过台风-不能。

1)没问题:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[self styleKit] apply];
    [self.window makeKeyAndVisible];
    return YES;
}

2),这是行不通的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    return YES;
}

-(void)initialize {
    [[self styleKit] apply];
    [self.window makeKeyAndVisible];
}

在第二种方式中,我使用台风,例如:
@implementation LAMainAssembly
-(AppDelegate *)appDelegate {
    return [TyphoonDefinition withClass:[AppDelegate class] configuration:^(TyphoonDefinition *definition) {
        [definition injectProperty:@selector(window) with:[self mainWindow]];
        [definition injectProperty:@selector(styleKit)];
        [definition performAfterInjections:@selector(initialize)];
    }];
}
@end

在这两种情况下,我都使用相同的样式高级版本,其中有:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

最佳答案

我认为这是因为台风在didFinishLaunchingWithOptions之前启动了它的初始化。

我建议避免依赖Typhoon初始化顺序,并在调用didFinishLaunchingWithOptions方法(您的第一种方法)后显式进行任何UI设置

关于ios - 为什么AppDelegate和通过台风的行为不同?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30831595/

10-15 05:03