我有一个带有一个默认操作和一个取消操作的操作表。如何更改默认操作文本颜色?
var refreshAlert = UIAlertController(title: "", message: "Are you sure you want to clear the entire message history? \n This cannot be undone.", preferredStyle: UIAlertControllerStyle.ActionSheet)
refreshAlert.addAction(UIAlertAction(title: "Clear message history", style: .Default, handler: { (action: UIAlertAction!) in
print("Handle Ok logic here")
// how to change this text color to red?
}))
refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction!) in
print("Handle Cancel Logic here")
}))
答案 0 :(得分:2)
你做不到。而是改变你的方法,如下所示:Apple为破坏性按钮提供了红色。
refreshAlert.addAction(UIAlertAction(title: "Clear message history", style: .Destructive, handler: { (action: UIAlertAction!) in
print("Voila !! button color is changed")
}))
答案 1 :(得分:0)
我认为没有直接的方法可以做到这一点。但是,你可以在这里申请一些丑陋的技巧:
for(i=0;i<WifiP2pDeviceList.size();i++){
WifiP2pDevice device = WifiP2pDeviceList.get(i);
String deviceName=device.deviceName;
String devicestatus=device.status;
//so on
}
操作表样式按钮完全相同的图像。UIAlertController
操作的image
属性传递,如下所示:- &GT;
Default