草庐IT

ios - UIDocumentInteractionController 不尊重 iOS 11 中 UINavigationBar 的 barTintColor 外观

coder 2023-09-10 原文

我有一个示例项目,可以在应用启动时设置栏色调颜色:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    UINavigationBar.appearance().barTintColor = UIColor.red
    return true
}

它有 1 个 View Controller (在 UINavigationController 内部),其中包含以下代码:

@IBAction func launchDocument(_ sender: Any) {
    if let url = Bundle.main.url(forResource: "example", withExtension: "pdf") {            
        let controller = UIDocumentInteractionController(url: url)
        controller.delegate = self
        controller.presentPreview(animated: false)
    }
}

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
    return self
}

在 iOS 10 中,主视图 Controller 和 UIDocumentInteractionController 都有红色的导航栏。在 iOS 11 中,UIDocumentInteractionController 不是红色的。这是 iOS 11 的错误吗?或者还有其他方法吗?

附言- 我知道我可以在委托(delegate)中返回 self.navigationController,但我需要 UIDocumentInteractionController 有一个“完成”按钮,而不是一个“后退”按钮

最佳答案

在 iOS 11 公开版本上也有同样的问题,从我的测试来看,到目前为止它看起来只遵循 [setBarStyle]

 [[UINavigationBar appearance] setBarStyle: UIBarStyleBlack];

关于ios - UIDocumentInteractionController 不尊重 iOS 11 中 UINavigationBar 的 barTintColor 外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46227858/

有关ios - UIDocumentInteractionController 不尊重 iOS 11 中 UINavigationBar 的 barTintColor 外观的更多相关文章

随机推荐