iOS popViewController 动画黑条出现

iOS popViewControllerAnimated black bar appear

我有两个 viewcontrollers.The 第一个 viewcontroller 没有状态栏。

class ViewController: UIViewController {

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

}

此外,我在 Info.plist 中将 UIViewControllerBasedStatusBarAppearance 设置为 YES。

第二个 viewcontroller 有状态栏。

class SecondViewController: UIViewController {

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

他们之间的关系是一个push segue。

最后一件事是我在 application:didFinishLaunchingWithOptions: 方法中将半透明 属性 设置为 false。

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

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

    return true
}

当我在导航条中点击返回时,有一个黑色的bar.How我可以去掉它吗?当我设置translucent为真时,黑色的条就没有了。

看完post Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7,我找到了解决办法

extendedLayoutIncludesOpaqueBars 设置为真。

func viewDidLoad() {
    extendedLayoutIncludesOpaqueBars = true // property introduced in iOS7,default value is false
}