我有一个UINavigationControllerUIViewController作为其根视图控制器。

let rootVC = Page1ViewController()   // extends UIViewController
let nav = UINavigationController(rootViewController: rootVC)
presentViewController(nav, animated: true) { () -> Void in
}

问题是rootVC的内容出现在导航栏下方。我试过了:
nav.navigationBar.translucent = false

这可行,但是我希望导航栏是透明的,并且我希望rootVC的内容不出现在导航栏的后面。

我也尝试过:
nav.edgesForExtendedLayout = UIRectEdge.None

但这不会改变任何东西。

在滚动时如何获得内容在其下滚动的透明导航栏,但在加载内容时不应出现在导航栏下?

最佳答案

删除此行:

nav.edgesForExtendedLayout = UIRectEdge.None

并在Page1ViewController的viewDidLoad中添加此行
self.edgesForExtendedLayout = UIRectEdge.None

希望能帮助到你。让我知道它是否无效,我会为您提供帮助。

关于ios - UINavigationBar下的UIViewController吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30042131/

10-14 22:13