ios - 如何更改输入的文本颜色?
问题描述
我正在制作一个脚本以允许用户更改元素颜色。
该脚本旨在处理按钮中的文本。
我试过这个:
func prettyText(_ button: RoundButton, colour: UIColor) {
button.textColor = colour
}
但它给出了这个错误:
“RoundButton”类型的值没有成员“textColor”;您指的是 'tintColor' 吗?
解决方案
UIButton
有setTitleColor(_:for:)方法。所以在你的情况下
func prettyText(_ button: RoundButton, colour: UIColor) {
button.setTitleColor(colour, for: .normal)
}
推荐阅读
- java - 在 Spring Boot 中实现 TDD,我不能在控制器中使用 @valid 注释
- android - 如何在矢量可绘制图像中添加圆形边框?
- jenkins - 在 Jenkinsfile 中使用“findFiles”,通过后缀匹配多个文件,使用 glob (ant glob)
- python - 网状不在docker内部创建多个线程?
- python - 无法导入python模块
- java - 在 JGroups 配置中放置 test-jgroups-jdbc_ping.xml jgroup 文件的位置
- python - 来自熊猫列切片的新列
- python - 如何在 discord.py 中删除机器人分页响应
- visual-studio-code - 从 vscode 打开自定义 url
- java - Selenium - 如何获得以下兄弟姐妹?