【问题标题】:How to change the bottom toolbar tint color without changing the navigator bar tint?如何在不更改导航栏色调的情况下更改底部工具栏色调颜色?
【发布时间】:2015-01-23 07:25:43
【问题描述】:

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

导航栏色调在storyboard中设置,工具栏色调在代码中设置。

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

但代码不起作用。

【问题讨论】:

    标签: ios objective-c swift uitoolbar tintcolor


    【解决方案1】:

    斯威夫特:

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

    【讨论】:

      【解决方案2】:

      在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

      【讨论】:

      • 我不是答案。我使用 .tintColor 但 .barTintColor。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-06
      • 1970-01-01
      • 2015-05-07
      相关资源
      最近更新 更多