Text spacing on iOS
Content should adapt to increased spacing between lines, words, letters, and paragraphs. This helps users with effectively reading text.
On iOS, you can use NSMutableParagraphStyle
for paragraphs:
lineSpacing
: set spacing between lineslineHeightMultiple
: multiply distance between lines by a numberparagraphSpacing
: set spacing between paragraphs
To adjust the spacing between letters you can use the NSKernAttributeName
attribute.
let style = NSMutableParagraphStyle()
style.lineSpacing = 20
style.lineHeightMultiple = 1.5
style.paragraphSpacing = 20
let attributedString = NSAttributedString(string: "Appt", attributes: [
.paragraphStyle: style,
.kern: 3.0
])
element.attributedText = attributedString