Search code examples
iosstatusbar

How can I set the background color of statusbar?


I want to set a background color like Facebook app's statusbar, but I can't find a way to fix it in Apple's documents. Is there any advice for me?


Solution

  • You cannot change the status bar color, as it has not background to change.

    However you could create a view on 20px height and place it behind the status bar.

    If you have a UINavigationBar, you could either remove the background color of a UINavigationBar or add a subview to the UINavigationBar with a height on 20px and give it the color of the status bar.

    I found this on github, you can inspect the code and find out how to change the color for the top 20px https://github.com/remirobert/RRMaterialNavigationBar