gpt4 book ai didi

swift - 如何更改 UIAlertController 中的一个 UIAlertAction 文本颜色

转载 作者:搜寻专家 更新时间:2023-10-31 08:20:33 25 4
gpt4 key购买 nike

如何更改 UIAlertController 中的一个 UIAlertAction 而不是所有操作按钮的文本颜色。

这是我的 UIAlertController 代码:我想将 Delete UIAlertAction 文本颜色更改为红色。

//Alert to select more method
func moreAlert()
{
let optionMenu = UIAlertController(title: "Mere", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet)

let Edit = UIAlertAction(title: "Rediger", style: .Default, handler: { action in

})


let Delete = UIAlertAction(title: "Slet", style: .Default, handler: { action in

})

let cancelAction = UIAlertAction(title: "Annullere", style: .Cancel, handler: { action in
print("Cancelled")
})

optionMenu.addAction(Edit)
optionMenu.addAction(Delete)
optionMenu.addAction(cancelAction)


self.presentViewController(optionMenu, animated: true, completion: nil)
}

最佳答案

在 Delete UIAlertAction 的初始化程序中使用参数 style: .destructive

关于swift - 如何更改 UIAlertController 中的一个 UIAlertAction 文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35905638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com