Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Does Things 3 Tint their Status Bar Text

Tags:

ios

swift

Things 3 Screenshot

In Things 3, the status bar text (wireless signal, time, battery, etc.) in the iOS app is a medium-gray color. Normally you can only have black or white text in the status bar.

How are they doing this?

My first guess is they have a semi-transparent white UIView covering the status bar, but I'm unsure how they pulled that off. I'd love to know how to do this in Swift.

like image 948
Clifton Labrum Avatar asked Nov 24 '25 20:11

Clifton Labrum


1 Answers

Here's some sample code in Swift that seems to mimic the Things 3 status bar effect pretty closely. In essence you're creating another window to place directly over the status bar that will mute the color slightly.

Important things to note in this example:

  • We assign the new UIWindow to a property, otherwise it will be released as soon as we leave the scope.
  • We set the windowLevel to UIWindowLevelStatusBar
  • We set isHidden to false instead of calling makeKeyAndVisible, since we still want the normal window to be the key window

AppDelegate.swift:

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var overlayWindow = UIWindow()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        overlayWindow.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 20)
        overlayWindow.windowLevel = UIWindowLevelStatusBar
        overlayWindow.backgroundColor = UIColor(white: 1, alpha: 0.4)
        overlayWindow.rootViewController = UIViewController()
        overlayWindow.isHidden = false

        return true
    }
}
like image 140
mclaughj Avatar answered Nov 27 '25 09:11

mclaughj