CPAlertViewController 3.0.0

CPAlertViewController 3.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期最后发布2016 年 10 月
SPM支持 SPM

Wei Zhao 维护。



  • 作者
  • Wei Zhao

CPAlertViewController

CPAlertViewController 是用 Swift 编写的自定义 Alert View Controller

灵感来自出色的 SweetAlert-iOSSCLAlertView-Swift。区别在于 CPAlertViewController 使用了自动布局。

屏幕截图

安装

手动安装

Classes/*.swift 拷贝到您的项目中是安装此库的最简单方法。

属性

这些属性是全局的,作用于整个项目。

/// The font size of tittle
public static var titleFontSize: CGFloat = 22.0

/// The font size of message
public static var messageFontSize: CGFloat = 16.0

/// The font size of button
public static var buttonFontSize: CGFloat = 16.0

/// The text color of tittle
public static var titleColor = UIColor.colorFromRGB(0x333333)

/// The text color of message
public static var messageColor = UIColor.colorFromRGB(0x555555)

/// The text color of button
public static var buttonTitleColor = UIColor.whiteColor()

/// The normal background color of button
public static var buttonBGNormalColor = UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 1.0)

/// The highlighted background color of button
public static var buttonBGHighlightedColor = UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 0.7)

用法

指定方法

public func show(title title: String?, message: String?, style: CPAlertStyle = .None, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

CPAlertViewController 还提供了四个便利方法

显示成功

public func showSuccess(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil) 

显示错误

public func showError(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

显示警告

public func showWarning(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

显示信息

public func showInfo(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

要求

  • Swift 3.0+

  • Xcode 8.0+

待办事项

  • [x] Cocoapods
  • [x] Carthage
  • [ ] Swift Package Manager

许可证

在 MIT 许可证下发布。请在 LICENSE 中查看详细信息。