Reputation: 1184
In swift, I am trying to add different colors to different buttons in a single option sheet. This is a sample:
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let reccommendAction = UIAlertAction(title: "Reccommend", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
print("Recommended")
})
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
(alert: UIAlertAction!) -> Void in
print("Cancelled")
})
optionMenu.addAction(reccommendAction)
optionMenu.addAction(cancelAction)
currentVC?.present(optionMenu, animated: true, completion: nil)
The task I wish to complete is to make the Recommend
button have a yellow tint color and the Cancel
button to have a red tint color. I have tried using optionMenu.view.tintColor
, however, that only allows for the setting of every cell, not individual ones.
Upvotes: 0
Views: 343
Reputation: 2874
You cannot change these colors. Be default when you are setting the action style to .cancel or .destructive it will have red color, it is enough in most cases. If you need to change this collors separately you have to create your own implementation of alert or use some already created libraries.
Upvotes: 3