UIBackButton Background Image not appearing

℡╲_俬逩灬. 提交于 2019-12-01 04:53:15

You may have more luck using a UIBarButtonItem and setting the back button background explicitly.

The appearance proxy has been unreliable in my own attempts to get a back button working with iOS 7. I experienced the same issue with the background not showing up properly first time showing the button.

If you just need to change the colour, try this[[UINavigationBar appearance] setTintColor:[UIColor redColor]];

If you want to change back button image you just need to write this 2 lines of code:

[self.navigationBar setBackIndicatorImage:[UIImage imageNamed:@"icon-back"]];
[self.navigationBar setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"icon-back"]];

And if you create sub class of UINavigationController it makes easy to customize you navigationbar and push & pop controllers

Try this:

self.navigationItem.hidesBackButton = NO;

if you're trying to add it to the Navigation bar then:

 UIImage* image4 = [UIImage imageNamed:@".....png"];
    button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 26, 26)];
    [button setBackgroundImage:....png forState:UIControlStateNormal];
    [button addTarget:self action:@selector(Selector)
         forControlEvents:UIControlEventTouchUpInside];
    [button setShowsTouchWhenHighlighted:YES];

    UIBarButtonItem *action = [[UIBarButtonItem alloc] initWithCustomView:button];
    NSArray *arr =[[NSArray alloc]initWithObjects:action, nil];
    self.navigationItem.rightBarButtonItems = arr;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!