这里是我的所有样式:
let normal = Style {
$0.font = UIFont.openSans(ofSize: 16)
}
let bold = normal.byAdding {
$0.traitVariants = .bold
}
let italic = normal.byAdding {
$0.traitVariants = .italic
}
let div = normal.byAdding {
let style = NSMutableParagraphStyle()
style.paragraphSpacingBefore = 130
$0.paragraph = style
$0.backColor = UIColor.red
}
let paragraph = Style {
let style = NSMutableParagraphStyle()
$0.paragraphSpacingBefore = 30
$0.paragraphSpacingAfter = 30
$0.paragraph = style
$0.backColor = UIColor.green
}
let ul = Style {
$0.paragraphSpacingBefore = 30
$0.paragraphSpacingAfter = 30
$0.tailIndent = 50
$0.backColor = UIColor.yellow
}
let li = Style {
$0.backColor = UIColor.blue
}
text.set(style: StyleGroup(base: normal, ["b": bold, "i": italic, "p": paragraph, "ul": ul, "li": li, "div": div]))
我需要在段落之间留一个间距。它们应该像div和html一样工作-换行和换行;)