How to set the title text color of UIButton?

后端 未结 7 1394
温柔的废话
温柔的废话 2020-12-13 05:18

I tried changing the colors of the text for a button, but it\'s still staying white.

isbeauty = UIButton()
isbeauty.setTitle(\"Buy\", forState: UIControlStat         


        
相关标签:
7条回答
  • 2020-12-13 06:09

    Swift UI solution

    Button(action: {}) {
                Text("Button")
            }.foregroundColor(Color(red: 1.0, green: 0.0, blue: 0.0))
    

    Swift 3, Swift 4, Swift 5

    to improve comments. This should work:

    button.setTitleColor(.red, for: .normal)
    
    0 讨论(0)
提交回复
热议问题