测试已测试 | ✓ |
Lang语言 | SwiftSwift |
许可 | MIT |
发布上次发布 | 2016年11月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由ghn、Noé Froidevaux维护。
需要 Swift3。
LiipKit 可通过 Liip CocoaPods 仓库获取。要安装它,只需将以下几行添加到您的 Podfile 中
pod "LiipKit"
要运行示例项目,请克隆仓库,然后先从 Example 目录中运行 pod install
。
将秒(Int)转换为小时:分钟:秒(String)
120.secondsToHoursMinutesSeconds() // => == "0:02:00"
将日期转换为字符串
date.toString() // => "08-03-2016
date.toString("dd.MM.yyyy") // => "08.03.2016"
date.toString("yyyy") // => "2016"
在本地化字符串前加波浪号
~"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()
方法 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)
提供一个属性 localizedTitle
,它可在 Interface Builder 中使用(请参阅 Example 项目中的 Main.storyboard)。
提供属性 localizedTitleForNormal
和 localizedTitleForHighlighted
,它们可在 Interface Builder 中使用(请参阅 Example 项目中的 Main.storyboard)。
十六进制初始化器
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)
提供一个属性 localizedText
,在 Interface Builder 中可用(参见示例项目中的 Main.storyboard)。
LiipKit 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。