UItextView background colours Linespacing area too

半城伤御伤魂 提交于 2020-01-01 07:17:21

问题


I am trying to replicate the text highlight (Not Search Text Highlight) in my UIText View. But I am Stuck with the colouring in the linespacing as well. How Can I rectify this ?

Current situation:

Desired Outcome:

I have added the following attributes to my UiTextview's Attributed Text

For Paragraph Line Spacing I have used the following

let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10

For Other Attributes I have used the following

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]

来源:https://stackoverflow.com/questions/51186667/uitextview-background-colours-linespacing-area-too

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!