着色UIBarButtonItem图像而不是背景

时间:2013-06-14 21:53:04

标签: ios uibarbuttonitem navigationcontroller tint

所以我有一个UITabBarController,我能够像这样的图像(我有一个用作背景的图像):

#define TAB_BAR_TINT_COLOR [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1.0]
#define TAB_BAR_SELECTED_TAB_COLOR [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]

[self.tabBarController.tabBar setTintColor:TAB_BAR_TINT_COLOR];
[self.tabBarController.tabBar setSelectedImageTintColor:TAB_BAR_SELECTED_TAB_COLOR];

产生这个:

http://img35.imageshack.us/img35/9885/z6po.jpg

但我似乎无法使用导航栏。每当我尝试调整barButtonItem的任何色调时,它都会改变背景:

    UIBarButtonItem *refreshBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"02-redo.png"] style:UIBarButtonItemStylePlain target:self action:nil];

    [self.navigationItem setRightBarButtonItem:refreshBarButtonItem];
    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor whiteColor]];

http://img580.imageshack.us/img580/1192/5gwf.jpg

非常感谢任何帮助 - 谢谢!

1 个答案:

答案 0 :(得分:0)

它应该工作。你在哪里写这段代码? - (无效)viewDidLoad中; ??