【发布时间】:2014-04-01 12:21:38
【问题描述】:
我正在对带有 appdelegate 外观的导航栏进行一些更改。
这是我的方法:
-(void) setAppearance{
NSMutableDictionary *titleBarAttributes = [NSMutableDictionary dictionaryWithDictionary: [[UINavigationBar appearance] titleTextAttributes]];
[titleBarAttributes setValue:[UIFont fontWithName:@"AvantGarde-ExtraLight" size:18] forKey:NSFontAttributeName];
[titleBarAttributes setValue:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
[[UINavigationBar appearance] setTitleTextAttributes:titleBarAttributes];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:6.0/256.0 green:57.0/256.0 blue:84.0/256.0 alpha:1.0]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
int borderSize = 3;
UIImageView *navBorder = [[UIImageView alloc] initWithFrame:CGRectMake(0,
41,
320,
borderSize)];
navBorder.image = [UIImage imageNamed:@"energy_line"];
navBorder.tag = 999;
[[UINavigationBar appearance] addSubview:navBorder];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
我的 appdelegate 中有一个方法将窗口设置为我的第一个 viewController,当我调用此方法时,我的 navBorder 会从导航栏中删除。我不明白为什么会发生这种情况,没有代码可以更改视图控制器中导航栏中的任何内容。
- (void)rootView
{
[self.window setRootViewController:initialViewController];
}
【问题讨论】:
标签: uiview navigationbar uiappearance