【问题标题】:How can I change text color on an input?如何更改输入的文本颜色?
【发布时间】:2018-10-19 05:23:37
【问题描述】:

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

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

我试过这个:

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

   button.textColor = colour

}

但它给出了这个错误:

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

【问题讨论】:

标签: ios swift


【解决方案1】:

UIButtonsetTitleColor(_:for:) 方法。所以在你的情况下

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-31
    • 2020-09-08
    • 2020-04-24
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    相关资源
    最近更新 更多