Created
November 1, 2017 01:10
-
-
Save MosheBerman/25dc26c82b68e2f6e6b579071a1abefd to your computer and use it in GitHub Desktop.
UIStatusBar Tint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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