Latest 0.0.1
Homepage https://github.com/phimage/AlertController
License MIT
Platforms osx 10.10
Authors

AlertController

License
Platform
Language
Issues
Cocoapod

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)

NSAlertController

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

NSAlertController

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.

  1. Add the project to your Podfile.

    use_frameworks!
    
    pod 'NSAlertController'
  2. Run pod install and open the .xcworkspace file to launch Xcode.

Using Carthage

github 'phimage/AlertController'

Latest podspec

{
    "name": "NSAlertController",
    "version": "0.0.1",
    "summary": "Share information between your applications and extensions",
    "homepage": "https://github.com/phimage/AlertController",
    "license": "MIT",
    "authors": {
        "phimage": "[email protected]"
    },
    "platforms": {
        "osx": "10.10"
    },
    "source": {
        "git": "https://github.com/phimage/AlertController.git",
        "tag": "0.0.1"
    },
    "source_files": "Sources/*.swift",
    "resources": [
        "Sources/*.{xib,icns}"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This