我想通过一些绿色动作来实现视图,并在UIAlertController中使选定的动作变为粗体。而其中一项行动,即解雇按钮必须与其他人分开,并以红色着色。如何在UIAlertAction中显示选定的动作?
我想添加他们的样式.cancel允许显示解雇按钮,但它是大胆的,但绿色。 我该如何做到这一点?
预期的观点:
我当前的代码:
let alertController
= UIAlertController(title: nil,
message: nil,
preferredStyle: .actionSheet)
let sortByDateAction = UIAlertAction(title: "По дате",
style: .default,
handler: {(action: UIAlertAction!) in
if self.sortBy != "date" {
self.page = 1
self.sortBy = "date"
self.loadTenders()
}
})
let moreExpensiveSortAction = UIAlertAction(title: "Дороже",
style: .destructive,
handler: {(action: UIAlertAction!) in
if self.sortBy != "priceHigh" {
self.page = 1
self.sortBy = "priceHigh"
self.loadTenders()
}
})
let cheaperSortAction = UIAlertAction(title: "Дешевле",
style: .default,
handler: {(action: UIAlertAction!) in
if self.sortBy != "priceLow" {
self.page = 1
self.sortBy = "priceLow"
self.loadTenders()
}
})
alertController
.addAction(sortByDateAction)
alertController
.addAction(moreExpensiveSortAction)
alertController
.addAction(cheaperSortAction)
alertController.preferredAction = sortByDateAction
alertController
.addAction(UIAlertAction(title: "Dismiss",
style: .cancel,
handler: nil))
显示你试过代码 –
你可以用图像显示一些预期的结果吗? – nayem
您可以将样式设置为.destructive红色解雇按钮 –