返回navigationItem标题&背景图片

时间:2011-11-18 11:35:46

标签: iphone uinavigationcontroller ios5 uinavigationbar back-button

我知道如何使用图片添加返回导航按钮或更改图块但我没有看到任何带背景图片及其标题的示例(@"back")。

我可以添加自定义背景图片和标题的自定义UIButton吗?

2 个答案:

答案 0 :(得分:3)

这,我最终在我的代码中做了什么实际上工作! 只需为不同的外观更新“forState”和“barMetrics”值。

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

答案 1 :(得分:1)

我不确定你的意思(@back)但是这里是我能够在后退按钮和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];

这是ios 5解决方案。谢谢你们这些消息来源: 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

相关问题