Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTareq Yaghmour
9,691 Pointsapplication.setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false) - Deprecated in iOS 9, How to fix?
I'm using Swift 2 to build this App. and right now i'm getting this error on the AppDelegate.swift
setStatusBarStyle(':animated:') was deprecated in IOS 9.0: Use -[UIViewController preferredStatusBarStyle]
David Park
Courses Plus Student 2,244 PointsI've inserted the code below on AppDelegate, right before return true. This worked.
application.statusBarStyle = .LightContent
3 Answers
Dennis Parussini
Treehouse Project ReviewerSorry, was a little busy and made a mistake. Instead of calling the method on the view controller you should indeed call
application.statusBarStyle = .LightContent
in
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
You also have to configure the info.plist to accept the changes. For this you go into info.plist and add a new Dictionary with
View controller-based status bar appearance and change the value to NO.
This way your status bar will be white no matter which view is on the screen.
Aubrey Taylor
2,991 PointsThis method worked great for me. Thanks!
Dennis Parussini
Treehouse Project ReviewerJust call this method in any UIViewController.
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}
David Park
Courses Plus Student 2,244 PointsHey Dennis, I've copied and pasted your code on the ViewController.swift. The status bar still stays black... Do I have to input anything on AppDelegate.swift? Thanks
mathewhucks
2,156 PointsI've added this to my ViewController but nothing happens. The status bar is still black. Any idea why? :)
Josman Perez
10,117 PointsPlease be aware that you also have to modified the info plist in your project management, so
1) set
View controller-based status bar appearance to YES
2) override in your view controller (or in the views you want to have a light status bar) with:
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent }
Anthony Babich
5,505 PointsAnthony Babich
5,505 PointsI am wondering about this as well. I tried the answer below and tbh am not even really sure what changes it is making to the status bar. I have no errors with this answer below, but nothing changes?