Reputation: 66242
I have a custom UILabel subclass. The only method I'm overriding is the drawRect
method, outlined here.
When I pass the UILabel's bounds.size
or frame.size
or layer.bounds.size
to - (CGSize)sizeThatFits:(CGSize)size
I am returned the value that the UILabel would be if not for the custom drawing. That is, the CGSize returned has too small a width since I'm increasing the spacing between letters.
What is the proper way to get the correct width, accounting for my custom drawing?
Upvotes: 1
Views: 107
Reputation: 385610
The proper way is to override sizeThatFits:
yourself to compute the proper size. UIKit can't do it for you.
Upvotes: 2