I have a similar question that when layout, some attributes of NSAttributedString make no effect and some others make effects not expected, so how to deal with them?
In my app, I need to increase the line space in paragraphs. Therefore, I set the paragraphStyle like this
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .justified
paragraphStyle.lineHeightMultiple = 1.6
paragraphStyle.paragraphSpacing = defaultFontSize * 2.0
paragraphStyle.hyphenationFactor = 1
for range in allMyRanges {
attributedString.removeAttribute(NSAttributedString.Key.paragraphStyle, range: range)
attributedString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: range)
}
When layout, all paragraphs with this paragraphStyle had the wrong frames and were also half covered by the paragraphs following them, like this:
Is there a way to control the frame of layoutFragments?
Topic:
UI Frameworks
SubTopic:
General
Tags: