ios - 呈现模态视图 Controller ,但不隐藏导航栏

标签 ios swift cocoa-touch

我以模态方式呈现一个带有半透明 View 的 viewController。这是一个自定义事件指示器。我希望它覆盖 View ,但让导航栏和标签栏可见且可访问。

文档和几个 SO 答案(例如 Presenting a Modal View Controller hides the Navigation Bar)似乎表明将模态呈现在导航 Controller 上应该可以实现这一点。但是当我这样做时,它正确显示了标签栏,但覆盖了导航栏。

有什么想法吗?相关代码如下:

let spinnerVC = SpinnerViewController()
spinnerVC.modalPresentationStyle = .overCurrentContext
spinnerVC.modalTransitionStyle = .crossDissolve
self.navigationController?.present(spinnerVC, animated: true, completion: nil)
//self.navigationController is definitely not nil

最佳答案

您可以出示您的 viewcontroller添加为 rootViewControllernavigationController然后将其呈现在当前 viewController 上像这样:

let spinnerVC = SpinnerViewController()
let navVC = UINavigationController(rootViewController:spinnerVC)
navVC.modalPresentationStyle = .overCurrentContext
navVC.modalTransitionStyle = .crossDissolve
self.present(navVC, animated: true, completion: nil)

关于ios - 呈现模态视图 Controller ,但不隐藏导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47565513/

相关文章:

iphone - 更新iOS SDK:是否会强制所有用户进行更新?

ios - 使用AVAudioPlayer播放音乐吗?

Swift + NSViewController 背景色(Mac App)

swift - 滚动时,表格 View 单元格中的值会发生变化,我在表格 View 中使用了原型(prototype)单元格。我的代码如下

ios - TableView Controller 没有显示 Assets 文件夹中的内容,或者根本没有显示任何内容

iphone - iOS YouTube和类似Safari的电影播放器

ios - 出现键盘时向上移动 View

iphone - iOS Storyboardsegue推送不起作用

ios - 发布带链接的 Facebook 照片

objective-c - 如何切割 UIView 内容?