A convenience around UIAlertController
, because sometimes you just want to say "OK".
UIAlertController
is awesome, but sometimes it's too much. How many times do you want to simply alert with a message and an "OK" button? Somewhat easy with UIAlertView
, certainly cumbersome with UIAlertController
, but simple with HEAlert
.
That's why I created HEAlert
.
Go from:
let alertView = UIAlertView(title: "Hello World", message: nil, delegate: nil, cancelButtonTitle: "OK")
alertView.show()
or:
let alertController = UIAlertController(title: "Hello World", message: nil, preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(action)
self.presentViewController(alertController, animated: true, completion: nil)
to:
HEAlert.ok("Hello World")
or:
HEAlert.ok("Hello World", presentingViewController: self)
- Xcode 8.0+
- Swift 3+
- iOS 8 (minimum, required)
With v1.0, HEAlert
has moved to Swift 3 and Xcode 8. If you need need Swift 2.2 support, use the v0.5.3
tag. There has been no explicit effort to support Swift 2.3.
With v0.5, HEAlert
has moved to Swift 2 and Xcode 7. If you still need Xcode 6.x (Swift 1.2) support, you can use older versions of HEAlert
such as v0.4.2.
Currently supports being installed by simple source code addition, by git submodule, or by Cocoapods (preferred).
You can easily obtain git as a submodule, and simply add HEAlert.swift
to your project. Off you go!
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 HEAlert 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 'HEAlert'
Then, run the following command:
$ pod install
Usage is fairly straightforward, and the code is fully documented. There's also an example application that demonstrates a simple usage of the class.
HEAlert.ok("Hello World")
or:
HEAlert.ok("Hello World", presentingViewController: self)
HEAlert.ok("Hello World", message: "This is my first HEAlert", presentingViewController: self)
You can customize a fair portion of the HEAlert
behaviors:
HEAlert.other("Do you like waffles?", message: "This is an important question", buttonTitle: "Yes", cancelTitle: "No", presentingViewController: self, cancelHandler: { (_) -> Void in
println("Must like pancakes instead")
}) { (_) -> Void in
println("Get the syrup!")
}
Easy display of an NSError
:
HEAlert.error(anNSError, presentingViewController: self, buttonHandler: nil)
- John C. Daub (@hsoi)
See included CHANGELOG.md
file.
BSD 3-clause “New” or “Revised” License. See included "License" file.