tounaobun
tounaobun

Reputation: 14857

iOS popViewControllerAnimated black bar appear

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

Upvotes: 1

Views: 521

Answers (1)

tounaobun
tounaobun

Reputation: 14857

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
}

Upvotes: 2

Related Questions