How to Show Alert & Sheet with Swift

This is example for show Alert & Sheet easily.
Simple alert:
alert(title: "Simple Alert")
Custom alert:
let yesAction = UIAlertAction(title: "Yes", style: .default) { (action) in toast(message: "Yes action", view: self.view) } let noAction = UIAlertAction(title: "No", style: .destructive) { (action) in toast(message: "No action", view: self.view) } alert(title: "Alert", message: "Custom alert", actions: [yesAction, noAction])
Simple sheet:
alert(title: "Simple Sheet", style: .actionSheet)
Custom sheet:
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in toast(message: "Cancel action", view: self.view) } let deleteAction = UIAlertAction(title: "Delete", style: .destructive) { (action) in toast(message: "Delete action", view: self.view) } alert(title: "Are you sure?", message: "You can not undo this action", actions: [cancelAction, deleteAction], style: .actionSheet)
Previously install AfriwanLib from this Github repository, then import AfriwanLib
on your class and you can use simple function above. There are still
many more functions from the library that make making iOS app easier and
faster.