LiipKit 0.3.0

LiipKit 0.3.0

测试已测试
Lang语言 SwiftSwift
许可 MIT
发布上次发布2016年11月
SwiftSwift 版本3.0
SPM支持 SPM

ghnNoé Froidevaux维护。



LiipKit 0.3.0

要求

需要 Swift3。

安装

LiipKit 可通过 Liip CocoaPods 仓库获取。要安装它,只需将以下几行添加到您的 Podfile 中

pod "LiipKit"

示例

要运行示例项目,请克隆仓库,然后先从 Example 目录中运行 pod install

文档

扩展

UI

Int 扩展

将秒(Int)转换为小时:分钟:秒(String)

120.secondsToHoursMinutesSeconds() // => == "0:02:00"

NSDate 扩展

将日期转换为字符串

date.toString() // => "08-03-2016
date.toString("dd.MM.yyyy") // => "08.03.2016"
date.toString("yyyy") // => "2016"

String 扩展

在本地化字符串前加波浪号

~"test" // => == NSLocalizedString("test", comment: "No comment")

方法:如果字符串为空或只包含空白字符则返回 true

"".isEmptyOrWhitespace() // true
"  ".isEmptyOrWhitespace() // true
"test".isEmptyOrWhitespace() // false

使用 .toDateTime 将字符串转换为 DateTime 对象

"2016-03-08T00:00:00.000+01:00".toDateTime()

UIAlertController 扩展

方法 show 允许显示警报而无需知道要显示警报所需的最顶层视图控制器。

let alert = UIAlertController(title: "Alert", message: "Alert message", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
alert.show(animated: true, completion: nil)

UIBarItem 扩展

提供一个属性 localizedTitle,它可在 Interface Builder 中使用(请参阅 Example 项目中的 Main.storyboard)。

UIButton 扩展

提供属性 localizedTitleForNormallocalizedTitleForHighlighted,它们可在 Interface Builder 中使用(请参阅 Example 项目中的 Main.storyboard)。

UIColor 扩展

十六进制初始化器

UIColor(hex: 0x0099FF)
UIColor(hex: 0x0099FF, alpha: 0.3)
UIColor(hexString: "0x0099FF")
UIColor(hexString: "#0099FF")
UIColor(hexString: "0x0099FF", alpha: 0.3)
UIColor(hexString: "#0099FF", alpha: 0.3)

简化解初始化器

UIColor(r: 0, g: 127.5, b: 255)
UIColor(r: 0, g: 127.5, b: 255, a: 0.5)

UILabel 扩展

提供一个属性 localizedText,在 Interface Builder 中可用(参见示例项目中的 Main.storyboard)。

作者

  • Noé Froidevaux
  • Manuel Escrig
  • Germain Hugon

许可证

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