AlertViewController - admiral-team/admiralui-ios GitHub Wiki
Class
An object that displays an alert message.
Declaration
public class AlertViewController: UIViewController, AnyAppThemable
Overview
Use this class to configure alerts and action buttons with the message that you want to display and the actions from which to choose.
Configure a Alert View Controller
Configuration alert view controller is similar UIAlertController.
let vc = AlertViewController()
vc.title = "Header"
vc.message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
vc.image = UIImage()
vc.modalPresentationStyle = .custom
vc.modalTransitionStyle = .crossDissolve
For presentation alert view controller use method present from UIViewController.
present(vc, animated: true, completion: nil)
Configure actions buttons
In addition to displaying a message to a user, you can associate actions with your alert controller to give people a way to respond. For each action you add using the addAction method, the alert controller configures a button with the action details. When a person taps that action, the alert controller executes the block you provided when creating the action object.
let action = AlertAction(title: "Good", style: .primary) { [weak self] _ in
self?.vc.dismiss(animated: true, completion: nil)
}
let secondAction = AlertAction(title: "Cancel", style: .alternative) { [weak self] _ in
self?.vc.dismiss(animated: true, completion: nil)
}
vc.addAction(action)
vc.addAction(secondAction)
Contribution
You can help us to find bugs or ask us to add features.
- To start
issue
please use ready-made templates. - To make changes to the repository, you need to create a
fork
of the project, make changes to the code and create apull request
in our project. You can read more about this in the Github documentation.