Search code examples
iphoneiosuibuttonuiappearance

UIBarButtonItem appearance setBackgroundImage black line under buttons


I have a little black line under all of my buttons which are in UIControlStateNormal. Back buttons and Done buttons are not affected.

Here is image:

enter image description here

You can clearly see it, and it's super annoying. Here is how I'm setting all of my images:

[[UIBarButtonItem appearance] setBackgroundImage:[UIImage imageNamed:@"nav-button"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

I'm using the same technique for back and done buttons, which doesn't have issues.


Solution

  • Try using [[UIImage imageNamed:@"nav-button"] resizableImageWithCapInsets:...]. Seems like your image is getting tiled because it's shorter than the button height.