
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.
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:
UIWindow to a property, otherwise it will be released as soon as we leave the scope.windowLevel to UIWindowLevelStatusBarisHidden to false instead of calling makeKeyAndVisible, since we still want the normal window to be the key windowAppDelegate.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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With