gpt4 book ai didi

ios - 快速更改占位符文本颜色

转载 作者:搜寻专家 更新时间:2023-10-31 08:09:17 26 4
gpt4 key购买 nike

如何通过 Swift 更改 UITextField 的占位符文本颜色?我似乎无法访问占位符属性。谢谢

最佳答案

您可以使用属性字符串 设置占位符文本。将颜色设置为属性属性(property)。

   textField.attributedPlaceholder = NSAttributedString(string:"placeholder text",
attributes:[NSForegroundColorAttributeName: UIColor.yellowColor()])

swift 5

textField.attributedPlaceholder = NSAttributedString(string:"placeholder text", attributes:[NSAttributedString.Key.foregroundColor: UIColor.yellow])

关于ios - 快速更改占位符文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27683383/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com