Swift UIAlertController按钮中禁用的颜色
我正在尝试创建一个UIAlertController,其中有两个具有默认文本颜色的操作按钮。代码如下:Swift UIAlertController按钮中禁用的颜色,swift,swift3,Swift,Swift3,我正在尝试创建一个UIAlertController,其中有两个具有默认文本颜色的操作按钮。代码如下: let refreshAlert = UIAlertController(title: "", message: msg, preferredStyle: .alert) refreshAlert.addAction(UIAlertAction(title: "No", style: .cancel, handler: { (action: UIAlert
let refreshAlert = UIAlertController(title: "", message: msg, preferredStyle: .alert)
refreshAlert.addAction(UIAlertAction(title: "No", style: .cancel, handler: { (action: UIAlertAction!) in
//dont bug user for permission for some time
}))
refreshAlert.addAction(UIAlertAction(title: "Notify me", style: UIAlertActionStyle.default, handler: { (action: UIAlertAction!) in
center.requestAuthorization(options: [.badge, .carPlay, .alert, .sound]) { (granted, error) in
print("Granted: \(granted), Error: \(error)")
}
UIApplication.shared.registerForRemoteNotifications()
}))
但我得到了以下输出:
为什么操作按钮的颜色为浅灰色?代码中是否有类似的行:
UIView.appearance().tintColor = .gray
设置视图的着色颜色似乎会影响按钮的颜色。您需要删除该行或根据需要进行调整
可考虑使用<代码>外观(何时)包含在里面实例其中:)代码>方法
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = UIColor(colorLiteralRed: 0/255.0, green: 122/255.0, blue: 255/255.0, alpha: 1.0)
您的代码中是否有类似的行:
UIView.appearance().tintColor = .gray
设置视图的着色颜色似乎会影响按钮的颜色。您需要删除该行或根据需要进行调整
可考虑使用<代码>外观(何时)包含在里面实例其中:)代码>方法
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = UIColor(colorLiteralRed: 0/255.0, green: 122/255.0, blue: 255/255.0, alpha: 1.0)
UIAppearance
协议是否在某处有效?是否在某处有效?