0

I am trying to replace the default backBarButtonItem image used by UINavigationControllers in my app. I want to use the following image (actually I am using a white arrow, but that wouldn't show here against the white background):

enter image description here

My image is 60 pixels wide and 33 pixels high, including empty space buffer around the arrow that I want to use to keep the arrow from being stretched too wide.

I've added the following code to my AppDelegate.m

UIImage *barButtonImage = [[UIImage imageNamed:@"icon-navbar-backbutton"] resizableImageWithCapInsets:UIEdgeInsetsMake(0,27,0,0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

The left inset is set to 27 points so that the head of the arrow isn't stretched. But when I run the code, I get the following result in the nav bar:

enter image description here

Why am I getting the extra white piece at the end of my backBarButtonItem?

4

1 回答 1

1

我认为你得到了这个结果,因为增加图像大小的默认模式是平铺。因此,您将一些白色部分和一些黑色部分平铺在箭头的右侧。您需要在右侧添加足够多的插图才能进入图像的白色部分,这样唯一平铺的就是箭头的直线部分。

于 2013-04-30T16:20:43.770 回答