TLDR; I found out that .usesFontLeading return the different result in iOS 13, but I want to know why ?
I have a bug in iOS 13 that my app shows the wrong text height. This bug does not happen in iOS 12.
I have the code to calculate the multi-line height of NSAttributedString.
I found that with different options, one has font leading, another one does not. The code returns different results.
let height_with_font_leading = text.boundingRect(with: constraintSize,
options: [.usesLineFragmentOrigin, .usesFontLeading],
context: nil).height
let height_with_no_font_leading = text.boundingRect(with: constraintSize,
options: [.usesLineFragmentOrigin],
context: nil).height
The height from the calculations are shown as images below.
As you see, the height without .usesFontLeading is correct, because the label can show full text without truncation.
- What is the purpose of
.usesFontLeading? - When should I use it ?
Here is the full snippet of my code:
https://gist.github.com/nRewik/7760ac31f107642c70eb9e659862ac3b

