Updated 22 February 2020
As you know most of the apps updates status bar as they desire but with the arrival of iOS 13 status bar’s view is no longer accessible through:
1 2 3 4 5 6 7 8 9 |
value(forKey: "statusBar") as? UIView OR extension UIApplication { var statusBarView: UIView? { return value(forKey: "statusBar") as? UIView } } |
To get the status bar view properties below code works for me in my project-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
extension UIApplication { var statusBarView: UIView? { if #available(iOS 13.0, *) { let tag = 38482 let keyWindow = UIApplication.shared.windows.first if let statusBar = keyWindow?.viewWithTag(tag) { return statusBar } else { guard let statusBarFrame = keyWindow?.windowScene?.statusBarManager?.statusBarFrame else { return nil } let statusBarView = UIView(frame: statusBarFrame) statusBarView.tag = tag keyWindow?.addSubview(statusBarView) return statusBarView } } else { return value(forKey: "statusBar") as? UIView } } } |
1 |
UIApplication.shared.statusBarView?.backgroundColor = UIColor(red: 231/255, green: 24/255, blue: 34/255, alpha: 1.0) |
You can know more about the Status bar view from here.
If you have any questions, then you can ask me!!
Thank You!!
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.