There seem to be two different ways to explicitly set the line height of an attributed string in iOS. Which is the preferred method and why?
https://developer.apple.com/documentation/uikit/nsmutableparagraphstyle/1524596-lineheightmultiple
https://developer.apple.com/documentation/uikit/nsmutableparagraphstyle/1524596-lineheightmultiple
Note that there are subtle differences to using these parameters, even if you are effectively setting the same distances.
The above shows lineSpacing applied. When selecting text, the spacing is visible below the lines of text. The last spacing is truncated.
The above shows lineHeightMultiple applied. The selection shows the spacing is above the lines of text. The top spacing is NOT truncated.
Line Spacing is the distance in CGFloat between two lines.
Line Height Multiple the space between each line equal to the value multiply with the line height. Imagine Line Height Multiple = number of new lines for each line.
ie: lineHeightMultiple = 2
will insert 2 "\n"
and lineHeightMultiple = 3
will insert "\n"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With