首页
\
问答
\
获取UITextField.placeHolder属性的前景色?(Get foreground color of UITextField.placeHolder property?)
获取UITextField.placeHolder属性的前景色?(Get foreground color of UITextField.placeHolder property?)
我正在尝试获取UITextField.placeHolder对象的前景色。 我必须使用NSAttributeString的以下成员之一:
attributesAtIndex(_:effectiveRange:) attributesAtIndex(_:longestEffectiveRange:inRange:) attribute(_:atIndex:effectiveRange:) attribute(_:atIndex:longestEffectiveRange:inRange:)
关于如何设置NSAttributeString的属性有一百万个示例,
uiTextFieldObject.attributedPlaceholder = NSAttributedString(string:"placeholder text", attributes[NSForegroundColorAttributeName: UIColor.redColor()])
但我找不到一个检索NSAttributeString属性值的简单示例。 任何帮助将不胜感激。
I'm trying to get the foreground color of a UITextField.placeHolder object. I have to use one of the following members of the NSAttributeString:
attributesAtIndex(_:effectiveRange:) attributesAtIndex(_:longestEffectiveRange:inRange:) attribute(_:atIndex:effectiveRange:) attribute(_:atIndex:longestEffectiveRange:inRange:)
There are a million examples on how to set attributes of an NSAttributeString,
uiTextFieldObject.attributedPlaceholder = NSAttributedString(string:"placeholder text", attributes[NSForegroundColorAttributeName: UIColor.redColor()])
But I cannot find a simple example that retrieves a NSAttributeString attribute value. Any help would be greatly appreciated.
原文:https://stackoverflow.com/questions/39441652
更新时间:2023-04-14 16:04