Alerts is a library that handles UIAlertController using the Method Chain pattern.
- Swift 5
- iOS 11.0+
You can use The Swift Package Manager to install Alerts by adding the proper description to your Package.swift file:
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
targets: [],
dependencies: [
.package(url: "https://github.com/devhplusn/Alerts.git", from: "1.0.0")
]
)
Then run swift package update.
Alerts is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Alerts', :tag => '1.0.0', :git => 'https://github.com/devhplusn/Alerts'
Alert Type
- Basic
Alert(title: "Title", message: "Message", tintColor: .black)
.addAction("OK", style: .default, isEnabled: true, titleColor: .black) { controller in
// you can handle here when user tapped this UIAlertAction
}.addAction("Cancel", style: .cancel)
.present(at: self)
- With textField
Alert(title: "Title", message: "Message", tintColor: .black)
.addTextField { textField in
// you can configuration textField.
} textDidChange: { controller, textField in
// you can handle it when the text of the textField changes.
}.textFieldDidChange { controller, index in
// you can handle it when the text of the textFields changes.
}.addAction("OK", style: .default, isEnabled: true, titleColor: .black) { controller in
// you can handle it when the user taps this UIAlertAction.
}.addAction("Cancel", style: .cancel)
.present(at: self)
ActionSheet Type
ActionSheet(title: "Title", message: "Message")
.addAction("OK", isEnabled: false) { controller in
// you can handle here when user tapped this UIAlertAction
}.addAction("Cancel", style: .cancel)
.present(at: self)
Alerts is available under the MIT license. See the LICENSE file for more info.