我正在尝试更改 iOS7 应用程序中 UINavigationBar 的外观。我正在执行以下操作:
- (void)viewDidLoad
{
[super viewDidLoad];
m_sNumberToCall = @"";
UIBarButtonItem * btn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"IconHome.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(btHomeTouched:)];
self.navigationItem.leftBarButtonItem = btn;
self.navigationController.navigationBar.translucent = YES;
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"TVCNavBack.png"] forBarMetrics:UIBarMetricsDefault];
NSShadow * shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0],
NSForegroundColorAttributeName,
shadow,
NSShadowAttributeName,
[UIFont fontWithName:@"Helvetica-Bold" size:21.0],
NSFontAttributeName,
nil]];
}
但是,我第一次展示 UITableViewController 它是标准的 iOS7 导航栏,然后我按下 home 并再次展示它,这是我的新外观。
任何想法为什么它第一次不起作用?