I am trying to create a very thin UIButton
with size = CGSizeMake(75, 23)
to fit a customized background image exactly. And I would like the button to have a title.
After I call setTitle:forState:
the button is resized to account for padding around the title, screwing up the background image (i.e. causing it to tile very unseemly). I have set the title font to quite a small size in the UILabel
subview, so it's not the font that's causing the problem but the padding. Thus I would like to remove this padding. The default values of the contentEdgeInsets
, imageEdgeInsets
and titleEdgeInsets
properties of UIButton
are all UIEdgeInsetsZero
, so I presume the padding is somewhere in the UILabel
subview. If so, I think I can eliminate it by subclassing UILabel
and overriding textRectForBounds:limitedToNumberOfLines:
but I'm not sure (and I'd be happy to hear from someone who has tried this). In any event, I'm looking for an easier way out.
I've searched and searched and haven't found anything.
Any suggestions?