UILabel should report when it is truncated

Originator:igeek1
Number:rdar://26863747 Date Originated:17-Jun-2016 09:40 AM
Status:Open Resolved:
Product:iOS Product Version:iOS 9.3.2
Classification:Enhancement Reproducible:Always
 
Area:
UIKit

Summary:
You should be able to query a UILabel to find out whether its text is truncated, or whether it is showing its full contents.

Steps to Reproduce:
1. Make a label that shows the description of something in an app.
2. Limit the label to, say, 3 lines.
3. Some items' descriptions will be longer than 3 lines.
4. Make a button with the title "Read More", which we want to show only when the label is truncated.
5. Look for a way to determine if the label is truncated.

Expected Results:
You can easily query a label for isTruncated, and that property would be KVO-able so you can respond to changes dynamically.

Actual Results:
There is no such property. You have to measure the text yourself. This is a shame, because text layout can potentially be expensive, depending on what you're doing, and it can be hard to get right. It would be preferable if UILabel would expose the property, which would presumably take advantage of the measuring work that it has already done.

Version:
iOS 9.3.2

Notes:


Configuration:
Any iOS device

Attachments:

Comments


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!