How to change one UIAlertAction text color in a UIAlertController

Viewed 4200

How do I change text color for one UIAlertAction in a UIAlertController and not all of the action buttons.

Here is my code for UIAlertController: I want to change Delete UIAlertAction text color to red.

//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)
}
2 Answers

Use the parameter style: .destructive in the initializer for your Delete UIAlertAction

Related