如何在不改变导航条着色的情况下更改底部工具条着色?

时间:2022-09-17 21:38:36

I want to set the navigator bar tint to white but the bottom tool bar tint to red.

我想把导航条调成白色,而底部工具条调成红色。

The navigator bar tint is set at storyboard, and the tool bar tint is set in code.

导航条着色在故事板上设置,工具条着色在代码中设置。

self.navigationController?.toolbar.tintColor=UIColor.redColor()

self.navigationController ? .toolbar.tintColor = UIColor.redColor()

But the code dose not work.

但是代码不能工作。

2 个解决方案

#1


2  

Swift:

迅速:

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()]
}

Objective-C:

objective - 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]];

#2


0  

In Objectivec-c

在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];

for more information click here

更多信息请点击这里

#1


2  

Swift:

迅速:

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()]
}

Objective-C:

objective - 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]];

#2


0  

In Objectivec-c

在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];

for more information click here

更多信息请点击这里