ios - 如何更改 iOS 系统警报的色调?
问题描述
我想更改 iOS 系统警报的色调颜色,例如要求访问照片库或 AppStore 审查的警报(不是您以编程方式创建和呈现的 UIAlertController),但我不知道这是否可能。
像这样使用窗口色调颜色不起作用:
self.window?.tintColor = UIColor.red
更改我的视图控制器视图的色调颜色也不起作用。
如果有可能怎么办?
解决方案
这是(Swift 4)的工作代码
tintColor
1.在 AppDelegate 中更改应用。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window?.tintColor = UIColor.red
return true
}
tintColor
2.从 ViewController更改应用程序。
let alert = UIAlertController(title: "Alert", message: "This is an alert.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
alert.view.tintColor = UIColor.red
self.present(alert, animated: true, completion: nil)
推荐阅读
- julia - 微分方程对我的微分方程“一无所有”
- python - pip freeze 的奇怪结果 - 包括不存在版本号的 Python 包和 Ubuntu 包
- python - Python Webdriver 需要帮助来测试找到的元素的“type()”以显示用户反馈。
- python - 如何在所有列上使用 MinMaxScaler?
- python-3.x - 从张量中获取值的随机索引
- prestashop - 保存产品 Prestashop 1.6.1.17 的问题
- javascript - airtable 获取请求 401(未经授权)
- jhipster - 为反应式微服务添加新的数据库选项
- sql - SQL Server:SUM 导致算术溢出,但实际上没有超过 INT 限制
- spring - Spring Boot MongoDB 副本集异常