富文本-定义

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import SwiftRichString




let normal = Style {
$0.font = SystemFonts.Helvetica_Light.font(size: 12)
}
let defaultType = Style {
$0.font = SystemFonts.Helvetica_Light.font(size: 12)
$0.color = UIColor.init(hexString: "#2993C9")
}
let redType = Style {
$0.font = SystemFonts.Helvetica_Light.font(size: 12)
$0.color = UIColor.red
}
let myGroup = StyleGroup(base: normal,["defaultType": defaultType,"redType": redType])
let str = "<defaultType>当前已选套餐:</defaultType>东风日产 <redType>¥800</redType> 租用40天"
v.taocan.attributedText = str.set(style: myGroup)