如何降低 xcode swift 中 TextField 的占位符(不是整个 TextField)的不透明度
how do I reduce the opacity of the placeholder (not the entire TextField) of TextField in xcode swift
我有一个示例登录页面。在那里,我有一个 textField。我只想更改文本字段占位符文本的 alpha 值(或不透明度)。我搜索了 google 但没有得到答案。请帮忙!
只需将占位符设置为属性字符串并根据需要设置颜色即可:
textField.attributedPlaceholder = NSAttributedString(string: "Placeholder", attributes: [NSAttributedStringKey.foregroundColor : UIColor.gray.withAlphaComponent(0.5)])
我有一个示例登录页面。在那里,我有一个 textField。我只想更改文本字段占位符文本的 alpha 值(或不透明度)。我搜索了 google 但没有得到答案。请帮忙!
只需将占位符设置为属性字符串并根据需要设置颜色即可:
textField.attributedPlaceholder = NSAttributedString(string: "Placeholder", attributes: [NSAttributedStringKey.foregroundColor : UIColor.gray.withAlphaComponent(0.5)])