Latest 1.1
Homepage https://github.com/tuanphung/UIAlertControllerExtension
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

An extension is written in Swift,

Allow to present a UIAlertController from any ViewController or anywhere.

Support both Alert & ActionSheet style.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+
  • Xcode 6.4

Installation

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:

$ gem install cocoapods

To integrate UIAlertControllerExtension into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'UIAlertControllerExtension', '~> 1.0'

Then, run the following command:

$ pod install

Usage

Presenting a Default Alert

import UIAlertControllerExtension

UIAlertController.present(title: "Title", message: "Message", actionTitles: ["OK", "Cancel", "Destroy"]) { (action) -> () in
   //Handle event callback
   println(action.title)
}

Presenting an Attributed Alert

import UIAlertControllerExtension

UIAlertController.present(title: "title",
                  message: "message", 
                  attributedActionTitles: [("OK", .Default), ("Cancel", .Cancel), ("Destroy", .Destructive)])  
                  { (action) -> () in
                      //Handle event callback
                      println(action.title)
}

Presenting a Default ActionSheet

import UIAlertControllerExtension

UIAlertController.present(style: .ActionSheet, title: "Title", message: "Message", actionTitles: ["OK", "Cancel", "Destroy"]) { (action) -> () in
   //Handle event callback
   println(action.title)
}

Presenting an Attributed ActionSheet

import UIAlertControllerExtension

UIAlertController.present(style: .ActionSheet,
                  title: "title",
                  message: "message", 
                  attributedActionTitles: [("OK", .Default), ("Cancel", .Cancel), ("Destroy", .Destructive)])  
                  { (action) -> () in
                      //Handle event callback
                      println(action.title)
}

License

UIAlertControllerExtension is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "UIAlertControllerExtension",
    "version": "1.1",
    "summary": "An extension allow you present an alert with new UIAlertController from any ViewController quickly.",
    "description": "Allow you present an UIAlertController with one of two styles (Alert or ActionSheet).nQuickly, Simply in use, and Event handling by closure.",
    "homepage": "https://github.com/tuanphung/UIAlertControllerExtension",
    "license": "MIT",
    "authors": {
        "Tuan Phung": "[email protected]"
    },
    "social_media_url": "https://twitter.com/tuanphunglk",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/tuanphung/UIAlertControllerExtension.git",
        "tag": "1.1"
    },
    "source_files": "Source/*.swift",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This