Skip to content

Instantly share code, notes, and snippets.

@MosheBerman
Created November 1, 2017 01:10
Show Gist options
  • Save MosheBerman/25dc26c82b68e2f6e6b579071a1abefd to your computer and use it in GitHub Desktop.
Save MosheBerman/25dc26c82b68e2f6e6b579071a1abefd to your computer and use it in GitHub Desktop.
UIStatusBar Tint
// Untested on iOS 11, untested with App Review. YMMV.
// MARK: - Theming the Status Bar
private func set(statusBar color: UIColor) {
guard let statusBarWindow = UIApplication.shared.value(forKey: "statusBarWindow") as? UIWindow else
{
print("Failed to get status bar window.")
return
}
guard let statusBar = statusBarWindow.value(forKey: "statusBar") as? NSObject else
{
print("Failed to get status bar object.")
return
}
let selector = NSSelectorFromString("setForegroundColor:")
if statusBar.responds(to: selector) {
statusBar.perform(selector, with: color)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment