问题描述:

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 ?

DELETE and CANCEL Button

 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 ...

网友答案:

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

相关阅读:
Top