4

So, I'm trying to make this:

enter image description here

i tried using UIView in back of Status bar and set the color to orange, but when running, The UIView displayed right under the status bar, so it's still White

i'm trying many solution in the internet but none of them work. Yes it works but when i move to other view controller and back again, The color dissapeared. What should I do? i'm using swift

Ariel Gemilang
  • 796
  • 2
  • 20
  • 42

1 Answers1

21
UIApplication.shared.statusBarStyle = .lightContent

UINavigationBar.appearance().clipsToBounds = true

let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView

statusBar.backgroundColor = UIColor.orange

Try using this code in your appDelegate's method application didFinishLaunchingWithOptions

Sarim Ashfaq
  • 286
  • 3
  • 10
  • 2
    There is an issue with this solution, when you double press the home button, this status status bar color will disappear. like the question(https://stackoverflow.com/questions/47250495/a-issue-on-changing-the-color-of-the-status-bar-when-switching-apps-on-iphone) – dengApro Nov 13 '17 at 22:42