1

I have two viewcontrollers.The first viewcontroller has no statusbar.

class ViewController: UIViewController {

    override func prefersStatusBarHidden() -> Bool {
        return true
    }

}

Also I have set UIViewControllerBasedStatusBarAppearance to YES in Info.plist.

The second viewcontroller has statusbar.

class SecondViewController: UIViewController {

    override func prefersStatusBarHidden() -> Bool {
        return false
    }
}

The relationship between them is a push segue.

enter image description here

The last thing is that I have set translucent property to false in application:didFinishLaunchingWithOptions: method.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    UINavigationBar.appearance().translucent = false
    UINavigationBar.appearance().barTintColor = UIColor.redColor()

    return true
}

When I click back in the navigationbar,there is a black bar.How can I get rid of it?When I set translucent to true,the black bar is gone.

enter image description here

tounaobun
  • 14,570
  • 9
  • 53
  • 75
  • Seems like it's applications main window background is showing since there a transparent space in your view. Fill that space up with something, and black bar won't be visible anymore. – NKorotkov Jul 03 '15 at 14:43

1 Answers1

2

After reading the post Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7,I have figured out a solution.

Set extendedLayoutIncludesOpaqueBars to true.

func viewDidLoad() {
    extendedLayoutIncludesOpaqueBars = true // property introduced in iOS7,default value is false
}
Community
  • 1
  • 1
tounaobun
  • 14,570
  • 9
  • 53
  • 75