ios - 在 SwiftUI 中自定义警报
问题描述
在使用 的iOS
应用程序中SwiftUI
,我使用这种代码设置了警报:
Alert(title: Text("Nice Title"),
message: Text("Some important message for the user."),
dismissButton: .none)
它有效,但我想更改一个细节。警报有一个蓝色的确定按钮。我想自定义它有一个灰色的确定按钮。
我尝试了一些调整,其中之一是:
Alert(title: Text("Nice Title"),
message: Text("Some important message for the user."),
dismissButton: .default(Text("OK").foregroundColor(.gray)))
但我的试验都没有奏效。
如果有人知道要走的路,请告诉我。
解决方案
把它放在显示 z 警报的视图中
init() {
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = .purple1
}
推荐阅读
- javascript - e参数如何知道它应该包含javascript回调函数中的事件对象的值
- flutter - 评估项目 ':spotify_sdk' 时出现问题。> 在项目 ':spotify_sdk' 中找不到路径为 ':spotify-auth' 的项目
- android - 如何在android中模拟用于单元测试的服务
- https - 如何在启用 tls 的情况下连接到 nomad/consul UI?
- git - 为什么 Git 文件/对象会损坏?
- r - Mac 的 jsonlite r.path.mac 错误 VS 代码
- python - 引导模式中的 Django 表单 POST 问题
- terraform - 如何从 Terraform 中的不同模块访问资源?
- reactjs - Strapi 在许多字段上上传文件但相同的 api
- r - 无法在 R 中加载 HTTP 资源 xml 解析