Skip to content

Instantly share code, notes, and snippets.

@oguzhanvarsak
Created January 21, 2022 12:41
Show Gist options
  • Save oguzhanvarsak/7f4efad57514929da47f14fa6e9ffa48 to your computer and use it in GitHub Desktop.
Save oguzhanvarsak/7f4efad57514929da47f14fa6e9ffa48 to your computer and use it in GitHub Desktop.
Alert View contains an Image View inside.
let showAlert = UIAlertController(title: "<#Title#>", message: "<#Message#>", preferredStyle: .alert)
let imageView = UIImageView(frame: CGRect(x: <#Int#>, y: <#Int#>, width: <#Int#>, height: <#Int#>))
imageView.image = <#UIImage#>
showAlert.view.addSubview(imageView)
let height = NSLayoutConstraint(item: showAlert.view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: <#Int#>)
let width = NSLayoutConstraint(item: showAlert.view, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: <#Int#>)
showAlert.view.addConstraint(height)
showAlert.view.addConstraint(width)
showAlert.addAction(UIAlertAction(title: "<#Button Text#>", style: .default, handler: { action in
<#Action#>
}))
self.present(showAlert, animated: true, completion: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment