Skip to content

Instantly share code, notes, and snippets.

@LovaRK
Created April 5, 2021 04:27
Show Gist options
  • Save LovaRK/b92836082548aad0d312ebca34a30e78 to your computer and use it in GitHub Desktop.
Save LovaRK/b92836082548aad0d312ebca34a30e78 to your computer and use it in GitHub Desktop.
extension UIViewController {
func statusBarColorChange() {
if #available(iOS 13.0, *) {
let app = UIApplication.shared
let statusBarHeight: CGFloat = app.statusBarFrame.size.height
let statusbarView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: statusBarHeight))
statusbarView.backgroundColor = UIColor.red
view.addSubview(statusbarView)
} else {
let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView
statusBar?.backgroundColor = UIColor.red
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment