UIBarButtonItem setBackgroundImage not working anymore in iOS7 iPad

孤者浪人 提交于 2019-12-11 12:38:41

问题


I have this appearance related code that was working fine in iOS 5:

-(void)customizeBackButton:(UIBarButtonItem*)backButtonItem {;
    [backButtonItem setBackgroundImage:[UIImage imageNamed:@"backbuttonitem"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}

This method is called within viewDidLoad in normal UIViewController.

Backbutton is a connected IBOutlet of a UIBarButtonItem, placed in a UIToolbar, and I am correctly seeing it when debugging. The point is that I can change tint and other appearances, but not the background images.

The code is working fine in iPhone (it's a universal app), and was working fine in iPad+iOS 5.

Am I doing something wrong or is there some kind of bug about UIBarButtonItem ?

This code is used everywhere in my app, because I have replaced default UINavigationBar back button to a normal UIBarButtonItem, because I needed to call some checking action before popping the controller.


回答1:


Try using the new API [UINavigationBar backIndicatorImage:backIndicatorImage].

It's documented here.



来源:https://stackoverflow.com/questions/19235804/uibarbuttonitem-setbackgroundimage-not-working-anymore-in-ios7-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!