Skip to content

Instantly share code, notes, and snippets.

@agiguere
Created August 29, 2019 12:55
Show Gist options
  • Save agiguere/7581c2978a592c7b33cfac3640d14d76 to your computer and use it in GitHub Desktop.
Save agiguere/7581c2978a592c7b33cfac3640d14d76 to your computer and use it in GitHub Desktop.
SAP Fiori for iOS SDK Code Snippet: Alert Controller Providing Protocol
import UIKit
/// Alert controller helper / utility methods
public protocol FUIAlertControllerProviding: class { }
public extension FUIAlertControllerProviding where Self: UIViewController {
/// Show an alert controller with 1 button
///
/// - Parameters:
/// - title: The title of the alert
/// - message: Description message
/// - buttonTitle: Action button to close the alert, default is OK
func showAlert(title: String? = nil, message: String, buttonTitle: String = "Ok") {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: buttonTitle, style: .default, handler: nil))
DispatchQueue.main.async {
self.present(alertController, animated: true, completion: nil)
}
//alertController.view.tintColor = overwrite default tint color by custom color
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment