RxAlert 1.1.2

RxAlert 1.1.2

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

xiaoyaogaojian 维护。



 
依赖
RxSwift~> 4.0
RxCocoa~> 4.0
 

RxAlert 1.1.2

  • 作者
  • xiaoyaogaojian

RxAlert

CI Status
Version
License
Platform

示例

要运行示例项目,请克隆仓库,并首先从示例目录运行 pod install

要求

RxSwift

安装

RxAlert 通过 CocoaPods 提供。要安装
它,只需将以下行添加到您的 Podfile 中

pod 'RxAlert'

用法

  1. 创建符合 AlertActionType 协议的操作

    enum AlertAction: AlertActionType {
    
      case cancel
      case delete
      case ok
    
      var title: String {
        switch self {
        case .cancel:
          return "Cancel"
        case .delete:
          return "Delete"
        case .ok:
          return "OK"
        }
      }
    
      var style: UIAlertActionStyle {
        switch self {
        case .cancel:
          return .cancel
        case .delete:
          return .destructive
        case .ok:
          return .default
        }
      }
    
      // Optional
      var isEnabled: Bool {
        return true
      }
    
    }
  2. 使用 UIAlertController.rx

    UIAlertController.rx
      .presented(
        by: self,
        title: "Title",
        message: "Some message",
        preferredStyle: .alert,
        actions: [AlertAction.ok, AlertAction.delete, AlertAction.cancel]
      )
      .subscribe(onNext: { action in
        switch action {
        case .ok: print("OK")
        case .delete: print("Delete")
        case .cancel: break
        }
      })
      .disposed(by: disposeBag)

使用演示获取更多信息。

作者

xiaoyaogaojian, [email protected]

许可证

RxAlert 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。