2017-02-27 80 views
-1

我要添加分享图片提醒消息标题代替标题文本。
我怎样才能用swift 3实现这个?添加图片在提示消息框中标题与Swift 3

let alertController = UIAlertController(title: "Share Movie", message: "Share this movie!", preferredStyle: .alert) 

    alertController.addAction(UIAlertAction(title: "Share", style: UIAlertActionStyle.default, handler: nil)) 
+0

你有没有回答你的问题? –

+0

我还没有尝试过呢@HardikShekhat。我会尽快尝试。在这些日子里我不好。这就是为什么。谢谢你问我。 :)我会回复结果。 –

+0

Hello bro @HardikShekhat,我现在试试你的代码。图像出现在警告框内,但我想在警告框标题中显示。目前,我删除标题文本。那么,我怎么能把这个图像放在标题位置兄弟? –

回答

4

试试这个。也许帮助你。

let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert) 

let action = UIAlertAction(title: "OK", style: .default, handler: nil) 

let imgTitle = UIImage(named:"imgTitle.png") 
let imgViewTitle = UIImageView(frame: CGRect(x: 10, y: 10, width: 30, height: 30)) 
imgViewTitle.image = imgTitle 

alert.view.addSubview(imgViewTitle) 
alert.addAction(action) 

self.present(alert, animated: true, completion: nil) 
+0

Hi bro @HardikShekhat兄弟,你能查看这个链接吗? http://stackoverflow.com/questions/42715152/add-image-into-uialertbox-in-swift-3我也遇到了另一个警报消息问题:( –