A colored alert view for your iOS.
Switch branches/tags
Nothing to show
Clone or download
Latest commit e4a603d Nov 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DEMO Support Swift 4.2 Sep 18, 2018
KRAlertController.xcodeproj Support Swift 4.2 Sep 18, 2018
KRAlertController Support Swift 4.2 Sep 18, 2018
KRAlertControllerTests Support Swift 4.2 Sep 18, 2018
.gitignore Initial commit Jun 18, 2016
.swift-version Support Swift 4.2 Sep 18, 2018
.swiftlint.yml Update Meta files Sep 15, 2016
.travis.yml Support Swift 4.2 Sep 18, 2018
KRAlertController.podspec Update email in podspec Nov 9, 2018
LICENSE Update LICENSE Nov 9, 2018
README.md Support Swift 4.2 Sep 18, 2018
README_Ja.md Support Swift 4.2 Sep 18, 2018

README.md

日本語

KRAlertController

Version License Platform Download Carthage compatible CI Status

KRAlertController is a beautiful and easy-to-use alert controller for your iOS written by Swift.

Requirements

  • iOS 10.0+
  • Xcode 10.0+
  • Swift 4.2+

DEMO

To run the example project, clone the repo, and open KRAlertControllerDemo.xcodeproj from the DEMO directory.

or appetize.io

Installation

KRAlertController is available through CocoaPods and Carthage. To install it, simply add the following line to your Podfile or Cartfile:

# Podfile
pod "KRAlertController"
# Cartfile
github "Krimpedance/KRAlertController"

Usage

(see sample Xcode project in /Demo)

Mainly the same as UIAlertController.

At first, import KRAlertController in your swift file.

Show simple alert.

KRAlertController(title: "Title", message: "message")
  .addCancel()
  .addAction("OK") { action, textFields in
    print("OK")
  }
  .show()

Initializer

init(title: String?, message: String?, style: KRAlertControllerStyle = .Alert)

Alert types

There is 7 kinds of alert. icon pass true to display glaph icon; otherwise, pass false. Default view controller to display alert is visible view controller of key window.

func show(presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> ())? = nil)
func showSuccess(icon icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> ())? = nil)
func showInformation(icon icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> ())? = nil)
func showWarning(icon icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> ())? = nil)
func showError(icon icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> ())? = nil)
func showEdit(icon icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> ())? = nil)
func showAuthorize(icon icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> ())? = nil)
// Example
alert.showSuccess(true)
alert.showWarning(true, presentingVC: self, animated: false) {
  print("Showed warning alert!")
}

Contributing to this project

I'm seeking bug reports and feature requests.

Release Note

  • 3.1.0

    • Compatible with Swift 4.2.
  • 3.0.1

    • Compatible with Swift 4.1.
  • 3.0.0

    • Supported Xcode9 and Swift4.

License

KRAlertController is available under the MIT license. See the LICENSE file for more info.