A NSViewController to display an alert message to the user.
This class replaces the NSAlert class and is inspired from UIAlertController.
After configuring the alert controller with the actions and style you want, present it using presentViewControllerAsSheet.
let controller = AlertController(title: "Alert title", message: "An alert message", preferredStyle: .warning)
parentVC.presentViewControllerAsSheet(controller)controller.add(action: AlertAction.dismiss(for: controller, title: "Ok"))controller.add(action: AlertAction(title: "Report...") { action in
NSWorkspace.shared().open(URL(string: "https://github.com/phimage/AlertController/issues")!)
})controller.addAction(title: "", style: .helpButton) { action in
// show error help
}controller.buttonsBar.color = NSColor.red
controller.buttonsBar.buttonSpace = 8- More customization
- align buttons left or right
- automatic helpButton on left
- Maybe input text fields
CocoaPods is a centralized dependency manager for Objective-C and Swift. Go here to learn more.
-
Add the project to your Podfile.
use_frameworks! pod 'NSAlertController'
-
Run
pod installand open the.xcworkspacefile to launch Xcode.
github 'phimage/AlertController'
