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];
UIButtonhasimageEdgeInsetsproperty, which can be used to shift image inside the button.In most cases it helps a lot. You can access it from IB (in
Edgedrop down chooseImageand then changeInsetfields), so you can try different values and see if it works for your situation.