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

标签 ios swift

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

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

我试过这个:

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

   button.textColor = colour

}

但它给出了这个错误:

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

最佳答案

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

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

关于ios - 如何更改输入的文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52886282/

相关文章:

ios - didSelectRowAtIndexPath 在调试器中没有任何错误

iOS View 就像 Facebook 应用程序中一样

ios - 如何使用 SWIFT3 解析此 JSON

ios - 每次 .insert() 或 .remove(at :) are called) 在 UserDefaults 中保存更新的 Set

ios - 如何调配 Swift.print(项目 :separator:terminator)

swift - 我应该使用什么替代 UITableViewAutomaticDimension 来在 NSTableView 中获得相同的效果?

ios - FW 和 TW 的自定义登录

ios - 任何方式都可以实现如图所示的功能

ios - 休斯顿 apn 推送不执行任何操作(无错误)

swift - Codable 错误 - 预期解码 Dictionary<String, Any> 但发现了一个数组