1

I searched all the topics about backbarbutton custom, but seems failed to find answers about my problem on backbarbutton.

To keep the property called interactivePopGestureRecognizer of UINavigationController, using leftBarButton to replace backBarButton is not a valid solution. But I want to custom the backbarbutton with a image, so I use the following code in my controller ViewDidLoad:

UIBarButtonItem * btnBack = [[UIBarButtonItem alloc]init];
btnBack.title = @"";
self.navigationController.navigationBar.backIndicatorImage = [UIImage imageNamed:@"backBtn"];
self.navigationController.navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:@"backBtn"];
self.navigationItem.backBarButtonItem = btnBack;

when I run my project, it shows just a blue rectangle in the place where backBarButton always show.

But the original image just like the system barbutton that called reply.

However, it has a different effect, just change to the image named "Drinks" which is a black image that show a glass of juice.

after run my project the place where always show backBarButton show a blue image just like "Drinks".

what happend! How can I custom my backBarButton with the giving image named backBtn.png, is there anyone can help me? Thanks in advance! For image submit has been reject, I discrible my problem in words.

Jolin_D
  • 11
  • 1
  • 3

1 Answers1

0

The Image has be transparent where there should be nothing to be drawn. It should be opaque where the content of the image will be drawn. At least that worked for me. The final color will be tinted by the navigationbar's tintColor anyway.

Helge Staedtler
  • 101
  • 1
  • 4