I am experiencing some problems with [UIBarButtonItem appearance]
for the the back button background image.
Normally (iOS 5 and iOS 6) I was able to set the background image of the back button like this:
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
But at iOS 7 the background image does not appear on the back button. The weird thing is, that the background image actually appears when the back button has been touched once.
I have tried setting the image for all states, to test if iOS 7 was using some kind of new state for an untouched back button, but that does not seem to be the case.
Do you have any idea, what I am doing wrong?
A solution which will make the background appear correctly on iOS7 is at OS 7 custom back button. It swizzles a method to fix the Apple bug (which is that they forget to call setNeedsDisplay on the private view when the background image is changed). Going borderless is probably better, if possible, but swizzling does work.
I searched for this problem and found that you are not the only one to have the same problem. There are many others who face the same issue with UIAppearance
. These are the proofs (to explain you to your client) :
In this case, what you can do is to follow the Answer provided in the 2nd Link.
You can either set the backIndicatorImage
property on UINavigationBar
to a custom image or you can change the color of the backIndicatorImage
by setting the tintColor
property on UINavigationBar
.
You can create a custom UIBarButtonItem
and manually assign it as UINavigationItem
's leftBarButtonItem
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With