我想更改导航栏的外观,到目前为止,我能够更改导航栏的背景图像以及颜色。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
//set the bg image of all nav bars
UIImage *navBackgroundImage = [UIImage imageNamed:@"navigationBackground.png"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
return YES;
//customizing the title text of the nav bars
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:255.0/255.0 green:250.0/250.0 blue:240.0/240.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Heiti TC" size:21.0], UITextAttributeFont, nil]];
}
这是我用来实现更改导航栏背景图像和颜色的代码。如果您查看第二个 UINavigationBar 外观声明,我尝试设置导航栏的字体
[UIFont fontWithName:@"Heiti TC" size:21.0]
但它不会改变字体。顺便说一句,我在 xcode 4.6.2 上使用 iphone 6.1 模拟器运行它。我确定字体名称是“Heiti TC”。