1

Is it possible to change status bar text color on other than default white and black? For example to red?

My app is targeting to iOS10, so I support the newest iOS SDK.

Kamil Harasimowicz
  • 4,684
  • 5
  • 32
  • 58

4 Answers4

1

I'm afraid not. We have only 2 modes:

public enum UIStatusBarStyle : Int {


    case `default` // Dark content, for use on light backgrounds

    @available(iOS 7.0, *)
    case lightContent // Light content, for use on dark backgrounds
}

You can find more info on How to change Status Bar text color in iOS 7

Community
  • 1
  • 1
7to4
  • 198
  • 1
  • 8
0

Try like this!

 func setStatusBarBackgroundColor(color: UIColor) {

        guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }

        statusBar.backgroundColor = color
    }
Bhupat Bheda
  • 1,968
  • 1
  • 8
  • 13
0

As per the apple documentation, there is no methods to change the colour of the status bar however you can add view on the top of the screen and set the background colour of that view.

0

As you can see you can change status bar background color using private framework. I have spend some time to investigate able to the change text color. This is possible with objective c runtime. But I thinks apple does not like this. You can modify your main.c to look like this

#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import "AppDelegate.h"

id testMethod(id object, SEL selector, NSUInteger style)
{
  return [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
}

int main(int argc, char * argv[]) {
  @autoreleasepool {
    BOOL result = class_replaceMethod(NSClassFromString(@"UIStatusBarForegroundStyleAttributes"), @selector(textColorForStyle:), testMethod, "@24@0:8q16");
      return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
  }
}

When you run you will see some thing like this:

NOTE: I does not investigate possible to change others colors, but I think it's real.

Sergey
  • 1,589
  • 9
  • 13