navigationItem更改字体颜色/ alpha?

时间:2011-02-01 12:55:29

标签: iphone objective-c cocoa-touch

有没有办法改变navigationItem上显示的文本的颜色或alpha?目前它的亮白色,我会(如果可能的话)喜欢将它击退一点,所以它不那么明亮。任何信息都将非常感激。

- (void)loadView {
    [[self navigationItem]setTitle:@"Location List"];
    ...
    ...

enter image description here

3 个答案:

答案 0 :(得分:4)

你需要使用setTitleView并给它一个标签 - 像这样:

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
titleLabel.textColor = [UIColor redColor];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.text = @"My Title";
[self.navigationItem setTitleView:titleLabel];

答案 1 :(得分:1)

答案 2 :(得分:0)

 UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
    titleLabel.textColor = [UIColor colorWithRed:0.0/255.0 green:77.0/255.0 blue:134.0/255.0 alpha:1.0];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.text = @"Videos";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [self.navigationItem setTitleView:titleLabel];
    //VKJ
相关问题