Images like these are used, making them stretchable. Basically, you want only the middle part of the image to be stretched when you resize the image, while the left and right cover should not be scaled to avoid distortion.
UIImage *buttonImage = [UIImage imageNamed:@"UINavigationBarDefaultButton.png"]; UIImage *stretchableButtonImage = [buttonImage stretchableImageWithLeftCapWidth:5 topCapHeight:0]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage:stretchableButtonImage forState:UIControlStateNormal];
In your case, why don't you just use UIBarButtonItem with UIBarButtonItemStyleDone or UIBarButtonItemStyleBordered as your style?
source share