Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JayachandraA/22e92b324e0b5788090137ec82985d87 to your computer and use it in GitHub Desktop.
Save JayachandraA/22e92b324e0b5788090137ec82985d87 to your computer and use it in GitHub Desktop.
//create object
let alertController = UIAlertController(title: "Share ♂", message: "Share the your content on social media.", preferredStyle: .actionSheet)
// create action objects
// which can be useed to handle the different action when user tapped on any one of them
let facebookAction = UIAlertAction(title: "Facebook", style: .default) { (action) in
//handle facebook button action
print("facebook button tapped")
self.performLogin(alertController: alertController)
}
let twitterAction = UIAlertAction(title: "Twitter", style: .default) { (action) in
//handle cancel button
print("twitter button tapped")
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in
//handle cancel button
print("cancel button tapped")
}
//add two button action to the alert controller
alertController.addAction(facebookAction)
alertController.addAction(twitterAction)
alertController.addAction(cancelAction)
//display
present(alertController, animated: true, completion: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment