我正在制作一个允许用户更改元素颜色的脚本。
该脚本旨在处理按钮中的文本。
我试过这个:
func prettyText(_ button: RoundButton, colour: UIColor) {
button.textColor = colour
}
但它给出了这个错误:
Value of type 'RoundButton' has no member 'textColor'; did you mean 'tintColor'?
最佳答案
UIButton
有 setTitleColor(_:for:)方法。所以在你的情况下
func prettyText(_ button: RoundButton, colour: UIColor) {
button.setTitleColor(colour, for: .normal)
}
关于ios - 如何更改输入的文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52886282/