Changing your status bar color in Swift


I want to share a very short tutorial with you today. It’s how to change the color of your status bar on your app. You know how they are often times white, but by default when you see what you have built in the simulator it shows up as black? It’s easy to change and it’s one of those little things that adds an extra bit of polish to your app.

First, open up your project in Xcode. In the very first section, where it says the build number and all that business, click on the section that says info. Here you will find a list of a bunch of different things, that frankly, I have no idea what they do. If you hover over any of these items you will see a plus and a minus sign. Double click to select the text in one of these boxes, and then start typing View controller-based status bar appearance. If you start typing view with a capital v, it should auto complete the form. Next, follow the row over to the right and if it says “yes” change it to a “no.”


When you are done with that, open up the AppDelegate from your list of files on the left hand side. Beneath the function that says didFinishLaunchingWithOptions, but before the return (I made that mistake when I was sleepy), type

application.setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)

After you start typing application.set StatusBarStyle Xcode will likely auto complete, but you still need to enter these parameters.


There are a few different options that you can use for the status bar. If you delete the .LightContent and then re-enter the ., Xcode will pull up a list of a few items. If you are curious about them you can access the documentation from the list.


Now, you are all done. If you run the simulator you should have updated your status bar from black to white. Niiiiiiiiice.