Ara*_*ell 2 uitextfield ios swift
假设我有一个这样的文本:“在注册时,我同意Rue.Du.8的使用条款和隐私政策” UITextField,我希望将除“使用条款”之外的整个颜色设为灰色。有可能实现成UITextField?

提前致谢 ...
您可以使用attributedPlaceholder属性来执行此操作,首先创建一个AttributedString,就像这样。
var str = "By signing up I agree to the Terms of use and Privacy policy of Rue.Du.8"
var attributedString = NSMutableAttributedString(string: str)
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.grayColor(), range: (str as NSString).rangeOfString(str))
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.whiteColor(), range: (str as NSString).rangeOfString("Terms of use"))
self.textField.attributedPlaceholder = attributedString
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
271 次 |
| 最近记录: |