Last active
April 28, 2020 14:32
-
-
Save alexnikol/36514525cf585f747409de413f410ad1 to your computer and use it in GitHub Desktop.
UIAlertController example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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