Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Last active April 28, 2020 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexnikol/36514525cf585f747409de413f410ad1 to your computer and use it in GitHub Desktop.
Save alexnikol/36514525cf585f747409de413f410ad1 to your computer and use it in GitHub Desktop.
UIAlertController example
//We can change preferredStyle: .actionSheet
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)
//Add Cancel Action
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
//Add Default Action
alert.addAction(UIAlertAction(title: "Default", style: .default, handler: { (action) in
print("Default action")
}))
//Add Default Action
alert.addAction(UIAlertAction(title: "Destructive", style: .destructive, handler: { (action) in
print("Destructive action")
}))
self.present(alert, animated: true, completion: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment