在消息框中添加图像(UIAlertController)
Add image in the message box (UIAlertController)
我正在使用 UIAlertController()
如何在我的消息框中仅添加 标题和图像 ,如下所示:
Swift 3.0
使用下面的代码
let alertMessage = UIAlertController(title: "My Title", message: "\n\n\n\n\n\n\n\n\n\n\n\n", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alertMessage .addAction(action)
self.present(alertMessage, animated: true, completion: nil)
let xPosition = self.view.frame.origin.x + 80
let imageView = UIImageView(frame: CGRect(x: xPosition, y: 100, width: 100, height: 100))
imageView.image = #imageLiteral(resourceName: "test.png")
alertMessage.view.addSubview(imageView)
没有 "OK" 按钮你不能在上面关闭 alertMessage.
根据您的要求设置 imageView
的 xPosition 和 y 以及 alertMessage
的消息。
我正在使用 UIAlertController()
如何在我的消息框中仅添加 标题和图像 ,如下所示:
Swift 3.0
使用下面的代码
let alertMessage = UIAlertController(title: "My Title", message: "\n\n\n\n\n\n\n\n\n\n\n\n", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alertMessage .addAction(action)
self.present(alertMessage, animated: true, completion: nil)
let xPosition = self.view.frame.origin.x + 80
let imageView = UIImageView(frame: CGRect(x: xPosition, y: 100, width: 100, height: 100))
imageView.image = #imageLiteral(resourceName: "test.png")
alertMessage.view.addSubview(imageView)
没有 "OK" 按钮你不能在上面关闭 alertMessage.
根据您的要求设置 imageView
的 xPosition 和 y 以及 alertMessage
的消息。