OKAlertController 1.1.0

OKAlertController 1.1.0

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布最后发布2017年3月
SPM支持 SPM

Oleh Kulykov 维护。




  • OlehKulykov

OKAlertController

可自定义的 UIAlertController 控制器。没有自定义 UI 或行为 - 使用更新后的标准 UIAlertController。

Alt text

使用方法

创建、自定义和显示/呈现

// Create alert controller as usual
let alert = OKAlertController(title: "Some title", message: "Some message")

// Fill with reqired actions
alert.addAction("Some option", style: .Default) { _ in
  // Process action
}

alert.addAction("Cancel", style: .Cancel, handler: nil) // Ignore cancel action handler

// Setup alert controller to conform design
alert.titleFont = ... /// <- Title text font
alert.titleColor = ... /// <- Title text color
... /// <- Any other customisation

alert.show(fromController: self, animated: true)

建议创建一个警报控制器的扩展或子类,一旦设置好样式以符合设计,就可以在任何项目部分重复使用。

请参见下面的示例

extension OKAlertController {
  // For instance your style called "Minimalistic", just create function to show this style of alert
  func showMinimalistic() {
    // Get root UIViewController, or you could use any other
    guard let rootController = UIApplication.sharedApplication().delegate?.window??.rootViewController else {
      return
    }

    // Setup style before show
    self.shadowColor = UIColor(white: 1, alpha: 0.79)
    self.backgroundColor = UIColor.whiteColor()
    ... /// <- Any other customisation

    // Finaly show alert controller
    show(fromController: rootController, animated: true)
  }
}


// Somewhere in the code
let alert = OKAlertController(title: "Some title", message: "Some message")
... /// <- Fill with actions
// Show "Minimalistic" style provided by bellow extension
alert.showMinimalistic()

要求

  • 最低 iOS:8.0
  • 适用于 iPhone 和 iPad

安装

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

pod "OKAlertController"

许可协议

MIT 许可协议 (MIT)

版权所有 © 2016 Oleh Kulykov [email protected]

特此免费授予任何取得此软件及其相关文档文件(“软件”)副本的人权,无条件地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许软件提供对象的人_DONE 处理,受下述条件约束:

软件上方的版权声明和本许可声明应包含在软件的所有副本或主要部分中。

该软件按“现供应”提供,不提供任何保证,明示或暗示的,包括但不限于适销性、适用于特定用途和不侵犯版权的保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论涉及合同行为、疏忽、侵权或其他,源自、因、与软件的使用或其他方式的联系。