The way you create the Edge tabs will keep the leftmost 3 and rightmost 3-points (or pixels) constant, and it stretches its head on the button. If you want the head size to be constant, you must turn it on the left side, leave 1 pixel stretchable, and then right. Assuming the image width is 50, you should write:
UIImage * buttonProfileDefault = [[UIImage imageNamed:@"Profile_Button_Default"] resizableImageWithCapInsets:UIEdgeInsetsMake(3, 46, 3, 3)];
However, this would make your photo located on the left side of the button. I recommend using two images:
- a modified image containing only the button border specified as the background image of the button
- image containing only the head specified as the image of buttons with a constant size
The code looks something like this:
UIImage *backgroundImage = [[UIImage imageNamed:@"border.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(3, 3, 3, 3)]; // in this case you can use 3, 3, 3, 3
[self.profileButton setBackgroundImage:backgroundImage forState:UIControlStateNormal];
UIImage *titleImage = [UIImage imageNamed:@"head.png"];
[self.profileButton setImage:titleImage forState:UIControlStateNormal];
Hope this helps!
source share