May*_*hyu 1 uialertview swift uialertcontroller uialertaction
我想在警报消息标题中添加共享图像而不是标题文本.
如何使用swift 3实现这一点?
let alertController = UIAlertController(title: "Share Movie", message: "Share this movie!", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Share", style: UIAlertActionStyle.default, handler: nil))
Run Code Online (Sandbox Code Playgroud)
试试这个.也许帮助你.
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)
Run Code Online (Sandbox Code Playgroud)