Kamagari 1.2.0

Kamagari 1.2.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2018年1月
SwiftSwift 版本4.0
SPM支持 SPM

Kazunobu Tasaka 维护。



Kamagari 1.2.0

Kamagari

Swift 中简单的 UIAlertController 构建类。

特性

  • AlertBuilder 类,通过方法链简单构建 UIAlertController
  • UIAlertController 扩展方法,简单显示 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)
}

要求

  • iOS 8.0+
  • Swift 3.0
  • Xcode 8.0

安装

  • 使用 CocoaPods 安装
pod 'Kamagari'
  • 将所有文件复制到您的项目中
  • 使用 git submodule

发布说明

请参阅 https://github.com/tasanobu/Kamagari/releases

许可证

Kamagari 在 MIT 许可下发布。请参阅 LICENSE 获取详细信息。