back navigationItem with title & background image

时间秒杀一切 提交于 2019-12-06 14:02:48

This, what I finally did in my code actually works!!! Just update "forState" and "barMetrics" values for different appearances.

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"myImage"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Mike Lyman

I'm not sure what you mean by (@back) but here is how I was able to get an image in the back button and the the UINavigationBar:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"myLogo.png"] forBarMetrics:UIBarMetricsDefault];

UIImage *backButton = [[UIImage imageNamed:@"HeaderTest.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

This is an ios 5 solution. Thank you to these sources: http://www.whypad.com/posts/ios-5-problem-setting-image-for-uinavigationbar/1011/

http://iosdevelopertips.com/user-interface/ios-5-customize-uinavigationbar-and-uibarbuttonitem-with-appearance-api.html

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