2

我想改变UINavigationBar titleColor.

我也想改textColorUINavigationBar backButton

我正在使用 iPhone Os sdk 3.1.2

4

5 回答 5

2

这对我有用。

使用它,您可以更改所有导航按钮的颜色:

 [[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];

将 redColor 替换为以下内容以调整按钮的颜色:

colorWithRed:0/255.0 green:144/255.0 blue:200/255.0 alpha:1.0// pick your color using this

一定要把它放在推送的视图控制器中。不是您想要查看此后退按钮颜色的视图控制器。

于 2012-08-20T17:40:53.283 回答
1

这个问题的一部分已经得到了回答

然后,要更改后退按钮标题颜色,我建议创建一个带有标签的自定义按钮:

UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:yourViewWithColoredText];
navigationItem.leftBarButtonItem = buttonItem; // assign it as the left button

yourViewWithColoredText应该是包含彩色文本的自定义视图。然后根据你的需要,你可以让它看起来像一个标准的后退按钮。

于 2009-11-05T11:27:22.360 回答
0

您可以将 UINavigationBar.h 中定义的 titleView 设置为:

 @property(nonatomic,retain) UIView *titleView;
// Custom view to use in lieu of a title. May be sized horizontally. Only used when item is topmost on the stack.

用你想要的任何颜色弹出你自己的 UILabel。

于 2009-11-05T11:24:26.250 回答
0
UIBarButtonItem *button = [[UIBarButtonItem alloc] init];
[button setTintColor:[UIColor redColor]];
于 2013-10-09T06:12:34.220 回答
0

在 iOS 5 和 6 上设置为title开启UINavigationBar

[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:UITextAttributeTextColor]];

在 iOS 7 上

self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor]};


textColor全部设置UIBarButtonItem

NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [UIColor blackColor], UITextAttributeTextColor,
                                    [UIColor clearColor], UITextAttributeTextShadowColor, nil];

[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState: UIControlStateNormal];
于 2014-05-06T09:54:41.530 回答