0

当我尝试更改SegmentControl的色调颜色时,它正在更改导航栏的barTintColor。如何停止导航barTintColor更改设置段颜色的tintColor?

如何阻止它请让我知道?

这是导航栏外观 enter image description here

码这是段控制

internal func wireUpUI() { 

     self.selectedSegmentIndex = 0 

     //DispatchQueue.main.async { 
      self.tintColor = Color.white 

      let segAttributesNormal: NSDictionary = [ 
       NSForegroundColorAttributeName: Color.white, 
       NSFontAttributeName: UIFont(name: set(), size: fontSize(.medium))! 
      ] 

      let segAttributesSelected: NSDictionary = [ 
       NSForegroundColorAttributeName: Color.theme, 
       NSFontAttributeName: UIFont(name: set(), size: fontSize(.medium))! 
      ] 

      self.setTitleTextAttributes(segAttributesNormal as? [AnyHashable : Any], for: UIControlState.normal) 
      self.setTitleTextAttributes(segAttributesSelected as? [AnyHashable : Any], for: UIControlState.selected) 
     // } 

     // Now bind the data 
     bindData(any: []) 
    } 
+2

你可以添加屏幕截图或部分代码吗? –

+0

为segmentControl选择你想要的viewController。在viewDidLoad中创建一个segmentControl。为您的segmentControl设置tintColor。这就是它 – Mannopson

+0

我在做同样的工作 –

回答

1

试试这个的viewDidLoad内:

let customSegmentedControl = UISegmentedControl (items: ["one","two","three"]) 

,并设置tintColor它。

customSegmentedControl.tintColor = UIColor.red 
+0

这是完美的作品。如果你有全球 – Mannopson

+0

谢谢,让我检查。 –

+0

谢谢,是的,它正在工作。 –