Change Status Bar Background Color in Swift 3

前端 未结 14 1592
挽巷
挽巷 2020-11-28 04:21

In XCode 7.3.x ill changed the background Color for my StatusBar with:

func setStatusBarBackgroundColor(color: UIColor) {
guard  let statusBar = UIApplicatio         


        
14条回答
  •  無奈伤痛
    2020-11-28 04:36

    Try this

    Goto your app info.plist

    1. Set View controller-based status bar appearance to NO
    2. Set Status bar style to UIStatusBarStyleLightContent

    Then Goto your app delegate and paste the following code where you set your Windows's RootViewController.

    #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v 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];
    }
    

提交回复
热议问题