In the context of UILabel
, If I were to calculate the height of the content I'm displaying... is it better to use textRect
or boundingRect
?
I would use boundingRect API.
As doc explains: You can use this method to compute the space required to draw the string. The constraints you specify in the size parameter are a guide for the renderer for how to size the string. However, the actual bounding rectangle returned by this method can be larger than the constraints if additional space is needed to render the entire string. Typically, the renderer preserves the width constraint and adjusts the height constraint as needed.
On the other hand, textRect doc states: You should not call this method directly.