【问题标题】:iOS popViewControllerAnimated black bar appeariOS popViewController 出现动画黑条
【发布时间】:2015-07-05 21:52:52
【问题描述】:

我有两个视图控制器。第一个视图控制器没有状态栏。

class ViewController: UIViewController {

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

}

我还在 Info.plist 中将 UIViewControllerBasedStatusBarAppearance 设置为 YES。

第二个视图控制器有状态栏。

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
}

当我在导航栏中点击返回时,有一个黑条。我怎样才能摆脱它?当我将translucent设置为true时,黑条消失了。

【问题讨论】:

  • 似乎它的应用程序主窗口背景正在显示,因为您的视图中有一个透明空间。用一些东西填充该空间,黑条将不再可见。

标签: ios swift uinavigationbar


【解决方案1】:

看了Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7的帖子,我想出了一个解决办法。

extendedLayoutIncludesOpaqueBars 设置为真。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 2013-12-21
    • 1970-01-01
    • 2023-03-26
    • 2021-01-07
    相关资源
    最近更新 更多