1

I am trying to make my UIStatusBar not translucent at all. While my UINavigationBar is completely white, I want the UIStatusBar to follow that behavior.

In my appDelegate - didFinishLaunchingWithOptions I was trying:

UIApplication.sharedApplication().statusBarStyle = .Default

But there is no way for me to set e.g. the alpha or translucency. Any ideas?

JVS
  • 2,592
  • 3
  • 19
  • 31

1 Answers1

1

1) In your info.plist file insert a new record with key "View controller-based status bar appearance" and set it to NO

2) In case the previous step does not work:

In your application(_:didFinishLaunchingWithOptions:) method of the AppDelegate.swift file put

UIApplication.sharedApplication().statusBarStyle = .LightContent // or .default

3) Try this inside your controller:

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .default
}

4) Put this in your viewDidLoad method:

self.setNeedsStatusBarAppearanceUpdate()
pedrouan
  • 12,762
  • 3
  • 58
  • 74
  • I have tried this, also with the plist. But I want it to be white with Black tint color – JVS Sep 17 '16 at 19:27
  • 1
    Answer updated. The code may differ as written in swift 3 – pedrouan Sep 17 '16 at 19:35
  • what exactly is the 3rd step doing? im not sure how to implement this. – JVS Sep 17 '16 at 19:44
  • Put it inside your controller like you would put a new method. It is new mode of setting of preferred color in Swift. – pedrouan Sep 17 '16 at 19:46
  • I think you meant override method rather than var. It is not working unfortunately. It is still translucent. – JVS Sep 17 '16 at 19:52
  • No, it is supposed to be use as-is in the comment above. It is standard getter only variable. Read docs here: https://developer.apple.com/reference/uikit/uiviewcontroller/1621416-preferredstatusbarstyle – pedrouan Sep 17 '16 at 19:57
  • Check my last answer update. :) maybe we forgot to put very important command. – pedrouan Sep 17 '16 at 19:59
  • sorry it is still not working. I am still getting an opaque status bar – JVS Sep 18 '16 at 10:08
  • Opaque is the opposite od translucent, isn´t it? – pedrouan Sep 18 '16 at 11:25
  • meant to write translucent – JVS Sep 18 '16 at 12:09
  • @JVS I have been confused, the param of a view controller status bar appearance should be set to YES, after I did additional research. – pedrouan Sep 24 '16 at 07:36