过渡到 UIDocumentInteractionController 接管导航栏标题颜色

发布于 2025-01-19 06:29:43 字数 815 浏览 4 评论 0原文

仅执行简单的过渡uidocumentInteractionController以显示PDF。它的标题是黑色的,这是必需的,但是我希望它返回时返回到应用程序颜色(白色)。试图强迫ViewWillAppear的更改无济于事(尽管我看到ViewWillAppear被称为)。我还尝试在DocumentInteractionControllerDidendPreview中更改颜色,但又一无所获。颜色保持黑色。 使用以下内容来改变颜色:

let textAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
self.navigationController?.navigationBar.largeTitleTextAttributes = textAttributes

给uidocumentInstractionController导航控制器:

open func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
        guard let vc = self.navigationController else {
            fatalError("No navigation controller")
        }
        return vc
}

在介绍文档和白色(或我想要的任何颜色)时,我该如何返回时,我该如何有黑色标题?这应该是简单的事情,但我一直在圈出。

Just doing a simple transition a UIDocumentInteractionController to display a PDF. Its title is black, which is desired, but I want it to go back to the app color (white) when it goes back. Trying to force a change in viewWillAppear does nothing (though I do see viewWillAppear is being called). I also tried changing the color in documentInteractionControllerDidEndPreview but again nothing happens. The color stays black.
Using the following to change the color:

let textAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
self.navigationController?.navigationBar.largeTitleTextAttributes = textAttributes

Giving the UIDocumentInteractionController the navigation controller:

open func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
        guard let vc = self.navigationController else {
            fatalError("No navigation controller")
        }
        return vc
}

How can i have a black title when presenting the document and white (or whatever color I desire) when i go back? This should be something simple but ive been going in circles.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花辞树 2025-01-26 06:29:44
let navBarAppearance = UINavigationBarAppearance()
    navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
    navBarAppearance.backgroundColor = .clear
    self.navigationController?.navigationBar.standardAppearance = navBarAppearance

在ViewDidload中调用此问题解决了问题

let navBarAppearance = UINavigationBarAppearance()
    navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
    navBarAppearance.backgroundColor = .clear
    self.navigationController?.navigationBar.standardAppearance = navBarAppearance

Calling this in viewDidLoad fixed the problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文