我有我的頂欄的問題,我初始化我MainViewController
顏色與在viewDidLoad
使用的功能:頂欄顏色變化,當我們改變觀點
-(void)_initCustomTopBar
{
NSLog(@"init");
UIColor *barColour = [UIColor colorWithRed:22.0f/255.0f green:61.0f/255.0f blue:121.0f/255.0f alpha:1.0f];
UIView *colourView = [[UIView alloc] initWithFrame:CGRectMake(0.f, -20.f, 320.f, 64.f)];
colourView.opaque = NO;
colourView.alpha = .7f;
//colourView.backgroundColor = barColour;
self.navigationController.navigationBar.barTintColor = barColour;
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar.layer insertSublayer:colourView.layer atIndex:1];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont
fontWithName:@"Helvetica Neue" size:20], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName, nil];
self.navigationController.navigationBar.titleTextAttributes = attributes;
}
但是,當我改變的頂部酒吧變灰,當我點擊返回MainViewController
頂部酒吧變得灰色了。 有一個想法,爲什麼它變成灰色?那有多正確?
呼叫'viewWillAppear' –
的方法展示你的'viewDidLoad' –
不,它是像以前一樣。 – user3227545