Parsa Yazdani
Parsa Yazdani

Reputation: 348

How can I change text color on an input?

I am making a script to allow users to change element colors.

The script is designed to work on the text in buttons.

I have tried this:

func prettyText(_ button: RoundButton, colour: UIColor) {

   button.textColor = colour

}

but it gives this error:

Value of type 'RoundButton' has no member 'textColor'; did you mean 'tintColor'?

Upvotes: 0

Views: 66

Answers (1)

Peter Tretiakov
Peter Tretiakov

Reputation: 3410

UIButton has setTitleColor(_:for:) method. So in your case

func prettyText(_ button: RoundButton, colour: UIColor) {
    button.setTitleColor(colour, for: .normal)
}

Upvotes: 2

Related Questions