Top Menu

Change status bar color in Swift

If your app has a dark background you might want to display the status bar (time, battery , carrier name and signal strengths) in a light/white colour so that users can still able to see it. Add the following code to your ViewController class to change your status bar colour from black to white:

override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}

change_status_bar_color_ios_swift

Results

change_status_bar_color_ios_swift_black

 

Swift is a powerful and intuitive programming language for iOS, OS X, and watchOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next project — or addition into your current app — because Swift code works side-by-side with Objective-C.

[ Swift ]

, , , , ,