EasyAttributedString
认识
🏵 介绍
EasyAttributedString 是一个工具包,使 AttributedString 更容易使用。
📋 要求
类型 | 要求 | |
---|---|---|
平台 |
iOS |
8.0+ |
macOS |
10.10 |
|
tvOS |
9.0 |
|
watchOS |
2.0 |
|
Linux |
不适用 |
|
IDE |
Xcode |
10.2+ |
语言 |
Swift |
5+ |
📲 安装
手动
将 EasyAttributedString
目录中的所有文件复制到您的项目中。
🛌 依赖
不适用
❤️ 贡献
欢迎您进行分叉并提交拉取请求。
🔖 许可
EasyAttributedString
是开源软件,采用 MIT
许可。
🔫 使用方法
import EasyAttributedString
let style = EAStyle {
$0.font = EASystemFonts.AmericanTypewriter.font(size: 25)
$0.color = #colorLiteral(red:0.99, green:0.44, blue:0.29, alpha:1.00)
$0.underline = (.patternDot, #colorLiteral(red:0.21, green:0.84, blue:0.98, alpha:1.00))
$0.alignment = .center
}
// et voilà!
let attributedText = "Hello World!".set(style: style)
import EasyAttributedString
let myStyle = EAStyle {
// define attributes...
}
EAStyleManager.shared.register("SomeStyle", style: style)
let label = UILabel.init()
label.styleName = "SomeStyle"
label.styledText = "Hello, <red>World</red>!"
import EasyAttributedString
let normal = EAStyle {
$0.font = EASystemFonts.Helvetica_Light.font(size: 15)
}
let red = normal.byAdding {
$0.color = #colorLiteral(red:0.80, green:0.20, blue:0.20, alpha:1.00)
}