我想改变我的iOS7应用程序UINavigationBar的外观。我做了以下内容:iOS 7 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导航栏,然后按我家,再次呈现它,它是我的新面貌。
任何想法,为什么它不能在第一次工作?
尝试在viewDidAppear中移动代码 – Ilario
我在那里尝试过,没有去过,我也试过在viewWillAppear。 – LilMoke
对于任何其他可能遇到山姆问题的人,我将此代码:[[UINavigationBar appearance] setBa ...更改为:[self.navigationController.navigationBar setBa ...以及setTitleTextAttributes行中的代码。找到答案在这里:http://stackoverflow.com/questions/17361500/how-to-set-navigation-bar-image-ins-ios-7 – LilMoke