0
import UIKit

class LoginController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = UIColor(r: 61, g: 91, b: 151)
    }

    override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return .lightContent

    }
}

extension UIColor {

    convenience init(r: CGFloat, g: CGFloat, b: CGFloat) {
        self.init(red: r/255, green: g/255, blue: b/255, alpha: 1)

whenever i change

override var preferredStatusBarStyle: UIStatusBarStyle {
        return UIStatusBarStyle.lightContent
}

i get threaded error that wouldn't let my simulator load

Shoaib
  • 2,286
  • 1
  • 19
  • 27
  • Why do you want to use preferredStatusBarStyle as a property? – Shoaib Oct 23 '16 at 19:48
  • Ah right, maybe I misunderstood your question. So you already tried the property approach but still get some error? – hnh Oct 23 '16 at 19:53

3 Answers3

1

preferredStatusBarStyle is a computed property, not a function as stated in your question.

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

Here's how it should be:

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

This should do the trick.

Alexander
  • 59,041
  • 12
  • 98
  • 151
  • 1
    It's not just a matter of replacing `func` with `var`. You also need to remove the parameter list (`()`), and change the `->` to `:` – Alexander Oct 23 '16 at 21:30
0

That's because it's a var, not a func. Try this:

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}
kpsharp
  • 455
  • 3
  • 10
0

The preferredStatusBarStyle is a property, not a function. Instead of

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

use

override var preferredStatusBarStyle : UIStatusBarStyle {
  return .lightContent
}
hnh
  • 13,957
  • 6
  • 30
  • 40