Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift UIAlertController按钮中禁用的颜色_Swift_Swift3 - Fatal编程技术网

Swift 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

我正在尝试创建一个UIAlertController,其中有两个具有默认文本颜色的操作按钮。代码如下:

  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
协议是否在某处有效?是否在某处有效?