Reputation: 231
I only need to display DELETE and CANCEL button as alert, no alert title or a message, and add action to DELETE button. Tried to modify following code but couldn't succeeded. And additionally, I want to make UIVIEW bit darker when DELETE and CANCEL buttons displayed. What is the best way to do this ?
let refreshAlert = UIAlertController(title: "Alert", message: "Are you sure ?", preferredStyle: UIAlertControllerStyle.Alert)
var imageView = UIImageView(frame: CGRectMake(220, 10, 40, 40))
let yourImage = UIImage(named: "delete")
imageView.image = yourImage
refreshAlert.view.addSubview(imageView)
refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in ...
Upvotes: 1
Views: 3529
Reputation: 2328
Some emojis have images , you can use these, This can be helpful for you if your image have standard emoji. please check LOCK emoji in example,>
UIAlertAction* HDQuality = [UIAlertAction
actionWithTitle:@"🔒 lockk Action"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:HDQuality];
Upvotes: 0
Reputation: 16456
This code will help:
let image = UIImage(named: "myImage")
var action = UIAlertAction(title: "title", style: .Default, handler: nil)
action.setValue(image, forKey: "image")
alert.addAction(action)
From: Add Image to UIAlertAction in UIAlertController
Upvotes: 1