测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可 | MIT |
发布最后发布 | 2017年10月 |
SwiftSwift 版本 | 4 |
SPM支持 SPM | ✗ |
由smalldu维护。
以上为示例图片
非常方便的链式调用
label1.attributedText = "属性字"
.attribute()
.fontSize(18)
.foreColor(UIColor.blue)
.underLine(.styleSingle)
.underLineColor(UIColor.black)
+
" 测试一下"
.attribute()
.font(UIFont.boldSystemFont(ofSize: 20))
.foreColor(UIColor.red)
.underLine(.styleDouble)
.underLineColor(UIColor.blue)
+
" ¥".attribute()
.font(UIFont.boldSystemFont(ofSize: 23))
.foreColor(UIColor.black)
+
" 2000"
.attribute()
.fontSize(19)
.foreColor(UIColor.purple)
.backgroundColor(UIColor.lightGray)
.fontSpace(3.5)
+
" 描边文字"
.attribute()
.fontSize(19)
.strokeColor(UIColor.blue)
.strokeWidth(3)
+
" 中划线 "
.attribute()
.fontSize(17)
.strike(2)
.strikeColor(UIColor.darkGray)
+
"带图片提示的文本"
.attribute()
.fontSize(15).foreColor(UIColor.lightGray)
.picture( UIImage(named: "warning"), bounds: CGRect(x: 0, y: 0, width: 13, height: 13), index: 0)
通常也会有一些属性文本需要点击的时候,并非链接或者@Someone,就普通的属性文本,这里也提供了支持
同样采用链式调用的方式
使用TextKit
所以使用TextView
比较方便
textView
.removeAllAttribute()
.appendAttributedText("温馨提示,谨防诈骗,跟您对话的可能是个骗子!!! "
.attribute()
.foreColor(UIColor.gray)
.fontSize(15)
.toEz())
.appendAttributedText(" 拉黑 ".attribute()
.foreColor(UIColor.blue)
.font(UIFont.boldSystemFont(ofSize: 17))
.toEz()
.addAction{
print("------这里是拉黑系统---------")
})
.appendAttributedText(" 举报 ".attribute()
.foreColor(UIColor.blue)
.font(UIFont.boldSystemFont(ofSize: 17))
.toEz()
.addAction{
print("------这里是举报系统---------")
})
以上基本可以满足日常开发需求。
Xcode 9
、Swift 4
、 iOS 8
EasyAtrribute 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 中:
pod 'EasyAtrribute'
smalldu,[email protected]
EasyAtrribute 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。