UIBarbuttonItem change the textColor

前端 未结 2 426
别跟我提以往
别跟我提以往 2021-01-25 07:43

I have these two buttons in a toolBar and wants to change the color of UIBarButtons how can i do such a thing? i\'ve tried setTitleTextAttributes, but it does not seem like it h

相关标签:
2条回答
  • 2021-01-25 08:12

    A UIBarButtonItem's color is its tintColor. (Or it can use the tintColor inherited from the toolbar you put it into.)

    0 讨论(0)
  • 2021-01-25 08:22

    It seems UIBarButtonItems won't change it's tint color once they are added to the navigation bar.

    What I did was to create a new one instead with new attributes.

    let rightBarButtonItem = UIBarButtonItem(title: "Title", style: .plain, target: self, action: #selector(someAction))
    rightBarButtonItem.tintColor = UIColor.white
    navigationItem.rightBarButtonItem = rightBarButtonItem
    
    0 讨论(0)
提交回复
热议问题