我想将导航栏色调设置为白色,但底部工具栏色调为红色。
导航栏色调在故事板上设置,工具栏色调在代码中设置。
self.navigationController?.toolbar.tintColor=UIColor.redColor()
但代码不起作用。
答案 0 :(得分:2)
夫特:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
var nav = self.navigationController?.navigationBar
nav?.barStyle = UIBarStyle.Black
nav?.tintColor = UIColor.whiteColor()
nav?.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()]
}
目标-C:
NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], UITextAttributeTextColor, [UIColor whiteColor], UITextAttributeTextShadowColor, nil];
[[UINavigationBar appearance] setTitleTextAttributes:textTitleOptions];
textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], UITextAttributeTextColor, nil];
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];
[[UIToolbar appearance] setTintColor:[UIColor redColor]];
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
答案 1 :(得分:0)
在Objectivec-c
中UIToolbar *doneToolbar=[[UIToolbar alloc]initWithFrame:CGRectMake(0,
self.view.frame.size.height-44, 320, 44)];
doneToolbar.translucent=NO;
doneToolbar.barTintColor=[UIColor redColor];
[self.view addSubview:doneTool bar];
有关详情,请点击here