Reputation: 15
I'm using UIAlertController()
how can I add just title and image in the my message box like this:
Upvotes: 1
Views: 1182
Reputation: 798
Swift 3.0
Use below code
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)
Without "OK" button you cannot to close above alertMessage.
Set xPosition and y of imageView
and message of alertMessage
as per your requirement.
Upvotes: 2