//this is the cancel button code
let cancelAction = UIAlertAction(title: "Cancel", style:
UIAlertActionStyle.cancel, handler: {(action) -> Void in
alert.dismiss(animated: true, completion: nil)})
cancelAction.setValue(UIColor.white(), forKey: "titleTextColor")
cancelAction.setValue(UIColor.equiaviaBlue(), forKey: "backgroundColor")
.....但是没有 backgroundColor forKey
。
有谁知道我在哪里可以找到 forKey
变量的参数列表?
最佳答案
AFAICT,titleTextColor
属性似乎没有在任何地方记录,这意味着以这种方式设置它可能构成私有(private) API 使用,并可能使您的应用程序被 App Store 禁止。如果 UIAlertAction
的内部实现在未来发生变化,它也可能导致您的应用程序崩溃。此外,使用类转储检查 UIKit 二进制文件,似乎没有任何明显的属性对应于背景颜色。因此,您可能无法完成您想要做的事情,而且无论如何也不建议这样做。
关于ios - swift : Where can I find a list of all the forkey arguments available for Alert actions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49100721/