TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jan 2018 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Kazunobu Tasaka.
Simple UIAlertController builder class in Swift.
The following sample codes shows how to use Kamagari in order to present UIAlertController.
// Alert Sample
AlertBuilder(title: "Question", message: "Are you sure where Kamagari is?", preferredStyle: .Alert)
.addAction(title: "NO", style: .Cancel) { _ in }
.addAction(title: "YES", style: .Default) { _ in }
.build()
.kam_show(animated: true)
// ActionSheet Sample
if UIDevice.currentDevice().userInterfaceIdiom != .Pad {
// Sample to show on iPad
AlertBuilder(title: "Question", message: "Are you sure where Kamagari is?", preferredStyle: .ActionSheet)
.addAction(title: "NO", style: .Cancel) { _ in }
.addAction(title: "YES", style: .Default) { _ in }
.build()
.kam_show(animated: true)
} else {
/*
Sample to show on iPad
With setPopoverPresentationProperties(), specify the properties of UIPopoverPresentationController.
*/
AlertBuilder(title: "Question", message: "Are you sure where Kamagari is?", preferredStyle: .ActionSheet)
.addAction(title: "YES", style: .Default) { _ in }
.addAction(title: "Not Sure", style: .Default) { _ in }
.setPopoverPresentationProperties(sourceView: view, sourceRect: CGRectMake(0, 0, 100, 100), barButtonItem: nil, permittedArrowDirections: .Any)
.build()
.kam_show(animated: true)
}
pod 'Kamagari'
See https://github.com/tasanobu/Kamagari/releases
Kamagari is released under the MIT license. See LICENSE for details.