测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2018年1月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由 Kazunobu Tasaka 维护。
Swift 中简单的 UIAlertController 构建类。
以下示例代码展示了如何使用 Kamagari 来显示 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'
请参阅 https://github.com/tasanobu/Kamagari/releases
Kamagari 在 MIT 许可下发布。请参阅 LICENSE 获取详细信息。