如何更改底部工具栏色调颜色而不更改导航栏色调?

时间:2015-01-23 07:25:43

标签: ios objective-c swift uitoolbar tintcolor

我想将导航栏色调设置为白色,但底部工具栏色调为红色。

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

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

但代码不起作用。

2 个答案:

答案 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