UItextView背景颜色也行距区域

时间:2018-07-05 08:31:01

标签: swift uitextview highlight nsattributedstring line-spacing

我正在尝试在UIText视图中复制文本突出显示(非搜索文本突出显示)。但是我也对线距中的颜色感到困惑。我该如何纠正?

当前情况:

enter image description here

所需结果:

enter image description here

我在UiTextview的属性文本中添加了以下属性

对于段落行距,我使用了以下内容

let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10

对于其他属性,我使用了以下内容

verseAttributes : [NSAttributedStringKey : Any] = [
NSAttributedStringKey(rawValue : NSAttributedStringKey.font.rawValue) : UIFont(name: "Helvetica", size:CGFloat(20*sizeMultiplier)) ?? 20,        
NSAttributedStringKey(rawValue : NSAttributedStringKey.foregroundColor.rawValue) : UIColor.darkGray,
NSAttributedStringKey(rawValue : NSAttributedStringKey.backgroundColor.rawValue) : UIColor.blue]
NSAttributedStringKey(rawValue : NSAttributedStringKey.paragraphStyle) : paragraphStyle]

0 个答案:

没有答案
相关问题