我想在警告消息 title 中添加 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)
关于swift - 使用 Swift 3 在警告消息框标题中添加图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42478380/