我只需要显示DELETE和CANCEL按钮作为警报,没有警报标题或消息,并向DELETE按钮添加操作。试图修改以下代码但无法成功。 另外,当显示DELETE和CANCEL按钮时,我想让UIVIEW变暗。这样做的最佳方式是什么?
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 ...
答案 0 :(得分:1)
此代码有助于:
let image = UIImage(named: "myImage")
var action = UIAlertAction(title: "title", style: .Default, handler: nil)
action.setValue(image, forKey: "image")
alert.addAction(action)
答案 1 :(得分:0)
有些表情符号有图像,你可以使用它们,如果你的图像有标准的表情符号,这对你有帮助。请在示例中检查LOCK表情符号,>
UIAlertAction* HDQuality = [UIAlertAction
actionWithTitle:@" lockk Action"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:HDQuality];