I made a subclass of UIButton, and I want to set a "padding". I want the button's frame to always be 15 pixels wider on each side, than the text.
In the drawRect method, I set the frame of the button to be 30 px wider than the text's width. But when I try to do this the frame does not get adjusted at all. Is this frame getting adjusted after I change the frame of my uibutton? How can I adjust the frame to set a padding?
Here is my code:
- (void)drawRect:(CGRect)rect{
[self setBackgroundImage:[[UIImage imageNamed:@"submitBtn.png"] stretchableImageWithLeftCapWidth:5 topCapHeight:0] forState:UIControlStateNormal];
[self setFrame:CGRectMake(rect.origin.x, rect.origin.y-90, self.titleLabel.frame.size.width + 30, self.frame.size.height)];
}
Thanks for the answers!!