UILabel sizeThatFits returns non-truncated width for single-line label

Number:rdar://FB7482776 Date Originated:12/6/19
Status:Open Resolved:No
Product:iOS & iPad OS > UIKit Product Version:
Classification:Incorrect/Unexpected Behavior Reproducible:
1. Create a UILabel with the default values (`lineBreakBehavior` is still `.byTruncatingTail`, `numberOfLines` is still `1`) and some very long text, like `"Very Very Very Very Very Very Very Very Very Very Text"`.
2. Call `sizeThatFits` on the label with a width of 250 and a height of 100

Expected Behavior: The size that fits should have a width of 250 or less because the label should know to truncate the text since it's too long.

Actual Behavior: The size that is returned is over 400, well over the size that was passed in to `sizeThatFits`

I have attached a playground that demonstrates this. In the playground, you'll see that if you set `numberOfLines` to `2` and set content that extends past 2 lines of content, everything works correctly. It is only for `numberOfLines` set to `1` that truncation is broken.

Xcode Version: 11.2.1


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!