Skip to content

Instantly share code, notes, and snippets.

@amarodeabreu
Last active February 23, 2021 09:29
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 amarodeabreu/7bc3793f2c56067fa9a1db161d1988ef to your computer and use it in GitHub Desktop.
Save amarodeabreu/7bc3793f2c56067fa9a1db161d1988ef to your computer and use it in GitHub Desktop.
// Function to display UIAlert when "Hit Me!" button is clicked
@IBAction func showAlert(){
//New instance of UIAlertController - Apple view controller
let showAlert = UIAlertController(title: "Hello, World", message: "This is my first swift app", preferredStyle: .alert)
//New instance of UIAlertAction - Apple view controller action
let action = UIAlertAction(title: "Awesome sauce", style: .default, handler: nil)
//Add action to view controller
showAlert.addAction(action)
//Present action on view controller with animation
present(showAlert, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment