1

i want to make the status bar translucent so that the it wont differ with the background image in app

i tried with this code

override func preferredStatusBarStyle() -> UIStatusBarStyle {
    return UIStatusBarStyle.LightContent
}

but it makes the status bar as white image

i need the status bar but it should be translucent.

for navigation bar i used this in didload

    self.navigationController?.navigationBarHidden = false      // Show navigationbar.

    self.navigationItem.leftItemsSupplementBackButton = true        // To add back button.

    self.navigationController?.navigationBar.topItem!.title = ""  // set nav bar title

    self.navigationController?.navigationBar.backItem?.title = "" //set back button text


    self.navigationController?.navigationBar.tintColor = UIColor(red: 0 / 255.0, green: 94 / 255.0, blue: 245 / 255.0, alpha: 1.0)

    //        setting navigation bar translucent background need 3 lines of code

    self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
    self.navigationController?.navigationBar.shadowImage = UIImage()
    self.navigationController?.navigationBar.translucent = true

any guess i am using simulator.

Aravindh Kumar
  • 1,213
  • 11
  • 22

3 Answers3

0

If you are using Autolayout:

Add a constraint for the background image which aligns the background with a constant of -20 to the top of the container view:

enter image description here

Stefan
  • 5,203
  • 8
  • 27
  • 51
-1

Find this steps:

1. Select Navigation bar from  Navigation Controller
2. Open Attribute inspector for selected navigation bar and set its bar tint as Clear Color
Bhagyalaxmi Poojary
  • 1,213
  • 1
  • 12
  • 17
-3
UIApplication.shared.statusBarView?.backgroundColor = .clear
Nik F
  • 71
  • 1
  • 11