AlertController
An NSViewController to display an alert message to the user. This class replaces the NSAlert class.
Install / Use
/learn @phimage/AlertControllerREADME
AlertController
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)
<img align="center" src="Demo/DemoInfo.png">
## Usage
Add a simple dismiss action
controller.add(action: AlertAction.dismiss(for: controller, title: "Ok"))
Add custom action
controller.add(action: AlertAction(title: "Report...") { action in
NSWorkspace.shared().open(URL(string: "https://github.com/phimage/AlertController/issues")!)
})
Choose a style
controller.addAction(title: "", style: .helpButton) { action in
// show error help
}
Customize buttons bar
controller.buttonsBar.color = NSColor.red
controller.buttonsBar.buttonSpace = 8
<img align="center" src="Demo/DemoAlert.png">
Todo
- More customization
- align buttons left or right
- automatic helpButton on left
- Maybe input text fields
Installation
Using CocoaPods
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.
Using Carthage
github 'phimage/AlertController'
