When the font size of my UILabel gets adjusted to fit the width of the label, the bottom of the text gets cut off. Here's a screenshot of the debug view:
The UILabel has the following characteristics:
Additional elements:
Things that did not work:
(As I was typing this question, I tried changing baselineAdjustment settings again to confirm it didn't work and this time, it worked. See answer.)
While I was typing out the answer and going back on every setting I had tried, setting the label's baselineAdjustement to .none fixed the issue.
label.baselineAdjustment = .none
FYI, the following documentations extracts were confusing to me:
From the documentation of UILabel baselineAdjustement:
The default value of this property is alignBaselines.
From the documentation of UIBaselineAdjustment:
.none: This is the default adjustment.
I'd be interested if anyone could confirm in the comments, but from my experiments, .none doesn't seem to be the default baselineAdjustment of UILabel. I had to specifically set the baselineAdjustment to .none to fix the bug mentioned in the question.
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