Latest 1.1.0
Homepage https://github.com/simorgh3196/SwiftyAlert
License MIT
Platforms ios 8.0, requires ARC
Authors

[CocoaPods]()
[GitHub release]()
[Swift version]()

Simple UIAlertController and UIAlertView wrapper.
Enable to use Swifty.

Installation and Setup

Installing with Carthage

github "simorgh3196/SwiftyAlert"

Installing with CocoaPods

To integrate SwiftyAlert into your Xcode project using CocoaPods, specify it in your Podfile and run pod install.

platform :ios, '8.0'
use_frameworks!
pod "SwiftyAlert", '~>1.1.0'

Manual Installation

To install SwiftyAlert without a dependency manager, please add Alert.swift to your Xcode Project.

How to use

  • Add import

    import SwiftyAlert
  • The most simple alert

    Alert(title: "AlertTitle").addOk().show(self)
  • Simple Alert

    Alert(title: "Alert", message: "Simple Alert.")
    .addDefault("OK")
    .show()
  • Action Sheet

    Alert(title: "ActionSheet", style: .ActionSheet)
    .addDefault("Take Photo") { print("take phote") }
    .addDefault("Open Library") { print("open library") }
    .addDestructive("Delete") { print("delete") }
    .addCancel()
    .handlePopoverController { [weak self] controller in    //for iPad
        controller?.sourceView = self?.view
        controller?.sourceRect = sender.frame
    }
    .show()
  • With TextField
    Alert(title: "Alert", message: "Alert with TextField.")
    .addTextField { textField in
        textField.placeholder = "ID"
    }
    .addTextField { textField in
        textField.placeholder = "Password"
        textField.secureTextEntry = true
    }
    .handleTextFieldDidChange { textField, index in
        print("Index of textFields:", index, "text:", textField.text)
        if textField.text?.characters.count > 5 {
            textField.text = ""
        }
    }
    .addDefaultWithTextField("Login") { textFields in
        textFields?.forEach({ print($0.text) })
    }
    .addCancel("Back") { print("Cancelled") }
    .show() { print("Completion") }

Advance

  • Change default text of addOk() and addCancel()
    Alert.okButtonTitle = "Go"
    Alert.cancelButtonTitle = "Back"

Message

Please report bug to @Sim_progra at Twitter.

Latest podspec

{
    "name": "SwiftyAlert",
    "version": "1.1.0",
    "summary": "Simple UIAlertController and UIAlertView wrapper.",
    "homepage": "https://github.com/simorgh3196/SwiftyAlert",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "simorgh3196": "[email protected]"
    },
    "social_media_url": "http://twitter.com/Sim_progra",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/simorgh3196/SwiftyAlert.git",
        "tag": "1.1.0"
    },
    "source_files": "SwiftyAlert/**/*.swift",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0.2"
}

Pin It on Pinterest

Share This