如何更改输入的文本颜色?

时间:2018-10-19 05:23:38

标签: ios swift

我正在制作一个脚本,允许用户更改元素的颜色。

该脚本旨在处理按钮上的文本。

我已经尝试过了:

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

   button.textColor = colour

}

但是它给出了这个错误:

  

“ RoundButton”类型的值没有成员“ textColor”;你是说'tintColor'吗?

1 个答案:

答案 0 :(得分:1)

UIButton具有setTitleColor(_:for:)方法。所以就你而言

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