有沒有辦法改變navigationItem上顯示的文字的顏色或alpha?目前它的明亮的白色,我會(如果可能的話)喜歡把它稍微敲回去,以免它不那麼明亮。任何信息將不勝感激。navigationItem更改字體顏色/ alpha?
- (void)loadView {
[[self navigationItem]setTitle:@"Location List"];
...
...
有沒有辦法改變navigationItem上顯示的文字的顏色或alpha?目前它的明亮的白色,我會(如果可能的話)喜歡把它稍微敲回去,以免它不那麼明亮。任何信息將不勝感激。navigationItem更改字體顏色/ alpha?
- (void)loadView {
[[self navigationItem]setTitle:@"Location List"];
...
...
您需要使用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];
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
你可能會想使用`[[UIC olor whiteColor] colorWithAlphaComponent:0.5f]`雖然... – 2011-02-01 13:41:13