How to set the title text color of UIButton? How to set the title text color of UIButton? swift swift

How to set the title text color of UIButton?


You have to use func setTitleColor(_ color: UIColor?, for state: UIControlState) the same way you set the actual title text. Docs

isbeauty.setTitleColor(UIColorFromRGB("F21B3F"), for: .normal)


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)


Example in setting button title color

btnDone.setTitleColor(.black, for: .normal)