测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可 | MIT |
发布最后发布 | 2016年9月 |
SPM支持 SPM | ✗ |
由 Adam Szeremeta 维护。
在 Swift 中创建属性字符串的简单易用方式
特性
.attributedString()
从普通字符串创建属性字符串+
运算符连接多个属性字符串支持的属性
首选方法是使用 CocoaPods。
use_frameworks!
pod 'ChainedAttributedString', '~> 1.0.0'
如果您由于某种原因无法使用 CocoaPods,则请从 ChainedAttributedString/
拉取文件并将其放入您的项目中。
只需通过调用 import ChainedAttributedString
导入库即可,现在您可以开始使用了!
示例操作
import ChainedAttributedString
//join strings
let one = "Test".attributedString() + "One".attributedString()
//apply attributes
self.exampleLabel.attributedText = "This sample text shows chained attributes".attributedString()
.textColor(UIColor.redColor(), forText: "sample")
.font(UIFont.boldSystemFontOfSize(20), forText: "This")
.kernSpacing(-1, forText: "text")
.strikeThrough(2, forText: "shows")
.strikeThroughColor(UIColor.blueColor())
.underline(2, forText: "attributes")
adamszeremeta, [email protected]
ChainedAttributedString
在 MIT 许可下发布。