gpt4 book ai didi

ios - UIAlertController 的外观

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:20:36 31 4
gpt4 key购买 nike

我想在应用程序中使用外观设置我的 AlertController 的外观。它适用于背景和按钮,但无论我尝试什么,标题和消息的标签始终保持黑色。

这是我正在做的:

UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = .orange
UIVisualEffectView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).effect = UIBlurEffect(style: .dark)
UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self]).textColor = .white

这是我得到的结果:

enter image description here

任何想法,如何设置标题和消息的颜色,或者为什么更改 UILabel 的外观在这种情况下不起作用?

最佳答案

最简单的方法是:不要。

您绝对不必局限于使用 UIAlertController 及其简单的默认 View 外观和内容。毕竟,它不过是一个呈现的 View Controller 。这意味着可以编写您自己的呈现 View Controller ,其外观和行为几乎类似于 UIAlertController 及其 View ,只是现在您完全负责其内容!

编写自己的类似警报的呈现 View Controller 比尝试侵入 UIAlertController 的 View 要好得多、更容易、也更可靠;前者是完全合法的,而后者除了不可靠之外,还可能导致您的应用程序被 App Store 禁止。

关于ios - UIAlertController 的外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53770631/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com