Reputation: 9419
I have custom button, with an image that I'd like to shift down within the button. I don't want to mess with the clickable portion of the button, but just want the image moved. I've tried adjusting button.imageview.frame, but it didn't seem to do anything.
Here's my code:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0, 0.0, 25.0, 25.0);
UIImage *buttonOnImage = [@"tabbar_icon_0"];
[button setImage:buttonOnImage forState:UIControlStateHighlighted];
[button setImage:buttonOnImage forState:UIControlStateSelected];
Upvotes: 2
Views: 834
Reputation: 1797
UIButton
has imageEdgeInsets
property, which can be used to shift image inside the button.
In most cases it helps a lot. You can access it from IB (in Edge
drop down choose Image
and then change Inset
fields), so you can try different values and see if it works for your situation.
Upvotes: 5
Reputation: 29498
Could you not adjust the image's size by padding it out with transparency in Photoshop?
Upvotes: 0