adit adit -5 years ago 144
iOS Question

How to adjust an UIButton's imageSize?

How can I adjust the image size of the UIButton? I am setting the image like this:

[myLikesButton setImage:[UIImage imageNamed:@"icon-heart.png"] forState:UIControlStateNormal];


However this fills up the image to the full button, how do I make the image smaller?

Answer Source

If I understand correctly what you're trying to do, you need to play with the buttons image edge inset. Something like:

myLikesButton.imageEdgeInsets = UIEdgeInsetsMake(top, left, bottom, right);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download