I have the following code repeated in many of my view controllers. I would like to refactor it into a global class/view controller. However, I still want it to be s
You can use SCLAlertView for simple alert creation. The alert is always shown from the current view controller and returns to this controller when the alert is closed. This static function shows a simple message with an OK button. Of course, you can also add text fields, buttons and other elements. These alerts are especially nice because you can call them at any point in your code, even from background queues.
class Alerts {
static func showAlert(title: String, message: String) {
DispatchQueue.main.async {
let alert = SCLAlertView()
alert.showCustom(title, subTitle: message, color: UIColor.blue, icon: UIImage(named: "logo")!, closeButtonTitle: "OK")
}
}
}