在警告消息框标题中添加图像 Swift 3
Add Image in Alert Message box Title with Swift 3
我想在警告消息 标题 中添加 Share Image 而不是标题文本。
我怎样才能用 swift 3 实现这个?
let alertController = UIAlertController(title: "Share Movie", message: "Share this movie!", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Share", style: UIAlertActionStyle.default, handler: nil))
试试这个。也许能帮到你。
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)
我想在警告消息 标题 中添加 Share Image 而不是标题文本。
我怎样才能用 swift 3 实现这个?
let alertController = UIAlertController(title: "Share Movie", message: "Share this movie!", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Share", style: UIAlertActionStyle.default, handler: nil))
试试这个。也许能帮到你。
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)