iOS popViewControllerAnimated黑条出现
我有两个viewcontroller。第一个viewcontroller没有状态栏iOS popViewControllerAnimated黑条出现,ios,swift,uinavigationbar,Ios,Swift,Uinavigationbar,我有两个viewcontroller。第一个viewcontroller没有状态栏 class ViewController: UIViewController { override func prefersStatusBarHidden() -> Bool { return true } } class SecondViewController: UIViewController { override func prefersStatusB
class ViewController: UIViewController {
override func prefersStatusBarHidden() -> Bool {
return true
}
}
class SecondViewController: UIViewController {
override func prefersStatusBarHidden() -> Bool {
return false
}
}
我还在Info.plist中将UIViewControllerBasedStatusBarAppearance
设置为YES
第二个viewcontroller具有状态栏
class ViewController: UIViewController {
override func prefersStatusBarHidden() -> Bool {
return true
}
}
class SecondViewController: UIViewController {
override func prefersStatusBarHidden() -> Bool {
return false
}
}
他们之间的关系是一个推动阶段
最后一件事是我在应用程序:didFinishLaunchingWithOptions:
方法中将半透明属性设置为false
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UINavigationBar.appearance().translucent = false
UINavigationBar.appearance().barTintColor = UIColor.redColor()
return true
}
当我在导航栏中单击“上一步”时,会出现一个黑色条。如何消除它?当我将translucent
设置为true时,黑色条消失了
看完这篇文章后,我想出了一个解决办法
将extendedlayoutincludesopaquebar
设置为true
func viewDidLoad() {
extendedLayoutIncludesOpaqueBars = true // property introduced in iOS7,default value is false
}
看起来它的应用程序主窗口背景正在显示,因为在您的视图中有一个透明的空间。用一些东西填满那个空间,黑条就看不见了。