bik*_*ota 13 uiactionsheet swift uialertcontroller
是否可以将取消按钮的颜色更改为红色,我知道我们可以使用破坏性样式
let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Destructive) { action -> Void in
print("Cancel")
}
Run Code Online (Sandbox Code Playgroud)
Igo*_*gor 18
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
cancelAction.setValue(UIColor.red, forKey: "titleTextColor")
Run Code Online (Sandbox Code Playgroud)
这是如何像你说的那样发出警报的代码:
let alert = UIAlertController(title: "Hello", message: "Hello World", preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Open in Google Maps", style: . default, handler: nil))
alert.addAction(UIAlertAction(title: "Open in Google", style: . default, handler: nil))
alert.addAction(UIAlertAction(title: "Copy Address", style: . default, handler: nil))
alert.addAction(UIAlertAction(title: "Cancel", style: .destructive, handler: nil))
Run Code Online (Sandbox Code Playgroud)
你必须使用2种风格.在这里,我用.destructive和.default,它将警报动作分成2部分
斯威夫特 4
你可以改变color的的警报操作使用下面的代码按钮。
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
cancelAction.setValue(UIColor.red, forKey: "titleTextColor")
Run Code Online (Sandbox Code Playgroud)
希望这对你有帮助。
小智 2
只需将按钮的样式属性设置为破坏性即可。
let cancelAction = UIAlertAction(title: "Cancel", style: .destructive, handler: {
(alert: UIAlertAction!) -> Void in
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6836 次 |
| 最近记录: |