2012-01-05 120 views

回答

2

您需要使用UILabel作为navigationItem的titleView。 根据您的要求将标签背景颜色设置为清晰的颜色和文字颜色。 然后将导航项目的titleview设置为此标签。

self.navigationItem.titleView = label; 
+0

是的,我也在讲同一件事.. :) – mAc 2012-01-05 07:16:19

+0

非常感谢.... – surendher 2012-01-12 12:12:49

0

您可以使用uinavigationbar的setTitleTextAttributes设置字体,颜色,偏移和阴影颜色。 这适用于ios 5.

0
CGRect frame = CGRectMake(0, 0, 200, 44); 
TitleLabel = [[[UILabel alloc] initWithFrame:frame] autorelease]; 
TitleLabel.backgroundColor = [UIColor clearColor]; 
TitleLabel.font = [UIFont boldSystemFontOfSize:14.0]; 
TitleLabel.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5]; 
TitleLabel.text = @"Nav Bar Title"; 
TitleLabel.textAlignment = UITextAlignmentCenter; 
TitleLabel.textColor = [UIColor colorWithRed:1 green:2 blue:4 alpha:0.7]; 
self.navigationItem.titleView = TitleLabel.text; 

You can take a UILabel, set its font, color alignment and add it on Navigation bar. 
Hope it works for you. 
相关问题