Search code examples
uinavigationcontrolleruikituinavigationbaruistatusbar

UIStatusBar Translucent Style


I've mentioned some new trends in "Segue-Navigation" paradigm from Apple. In apps like Apple Music, Health or News all main "start-point" controllers do not have navigation bar. Instead - there is a big bold beautiful title. I'd like to do the same in my app. I created UITableViewController with static cells. The first one contains title of controller.

But when I scroll up, status bar merges with this cell, so I want this cell to be behind of status bar like in Apple apps.

My UITableViewontroller

VC and Status bar conflict

Apple's solution


Solution

  • Solution

    let statusBarView = UIView(frame: CGRect(x:0, y:0, width:view.frame.size.width, height: UIApplication.shared.statusBarFrame.height))
    let blurEffect = UIBlurEffect(style: .light)
    let blurEffectView = UIVisualEffectView(effect: blurEffect)
    blurEffectView.frame = statusBarView.bounds
    blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    statusBarView.addSubview(blurEffectView)
    UIApplication.shared.windows.first?.addSubview(statusBarView)