Set the status bar to black colour

后端 未结 5 715
盖世英雄少女心
盖世英雄少女心 2020-12-10 09:22

I want to set the colour of the status bar (The small strip on top where the clock and battery is displayed) to black background with white text. How can I do

5条回答
  •  -上瘾入骨i
    2020-12-10 09:43

    Goto Plist file

    a) Set the value "View controller-based status bar appearance" to NO
    b) Set the value "Status bar style" to UIStatusBarStyleLightContent 
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
    #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(version)  ([[[UIDevice currentDevice] systemVersion] compare:version options:NSNumericSearch] != NSOrderedAscending)
    
        if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
        {
            UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 20)];
            view.backgroundColor=[UIColor blackColor];
            [self.window.rootViewController.view addSubview:view];
        }
        return YES;
    }
    

    It fixed status bar color for me. Hope it helps.

提交回复
热议问题