如何通过代码设置导航栏的标题颜色?
答
您可以使用uinavigationbar的setTitleTextAttributes设置字体,颜色,偏移和阴影颜色。 这适用于ios 5.
答
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.
您到目前为止尝试过什么?对于初学者,你有没有看过[UINavigationBar]的开发者文档(http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html)? – 2012-01-05 07:12:24