Search code examples
iosswiftuikituinavigationbaruistatusbar

UIBlurEffect on StatusBar only (not on UINavigationBar)


Similar to this: How to make a Navigation Bar and Status Bar blurred (UIBlurEffect)? iOS, Swift 3

but we'd like to apply the UIBlurEffect on the StatusBar only, not the navigationbar. Is this possible?


Solution

  • You can get your statusBar view by following code, then try add to visual effect like here

         let statWindow = UIApplication.shared.value(forKey:"statusBarWindow") as! UIView
            let statusBar = statWindow.subviews[0] as UIView
    //        statusBar.backgroundColor = UIColor(red: 23 / 255.0, green: 0 / 255.0, blue: 154 / 255.0, alpha: 0.7)
            statusBar.backgroundColor = UIColor(red: 213 / 255.0, green: 0 / 255.0, blue: 0 / 255.0, alpha: 0.7)