Created
August 29, 2019 12:55
-
-
Save agiguere/7581c2978a592c7b33cfac3640d14d76 to your computer and use it in GitHub Desktop.
SAP Fiori for iOS SDK Code Snippet: Alert Controller Providing Protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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