2017-02-27 77 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我也遇到了另一個警報消息問題:( –