2016-08-13 12 views
1

私はUITextFieldの中に「Rue.Du.8の利用規約とプライバシーポリシーに同意します」というような文章がありますので、「利用規約」を除いて全体の色を灰色にしたい白色 。 UITextFieldに到達することは可能ですか?UITextField内のテキストの部分をハイライト表示するにはどうすればよいですか?

enter image description here

事前のおかげで...

+0

あなたが条件を作ることができるように、このhttp://stackoverflow.com/questions/27728466/use-multiple-font-colors-in-a-single-label-swift –

+0

は私がテキストビューを使用します見ます使用とプライバシーのリンクが機能します。テキストフィールドにはその機能がありません。 –

答えて

3

あなたは、まずこのように、AttributedStringを作成し、attributedPlaceholderプロパティを使用してこれを行うことができます。

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 
+0

完璧に働いています。 –

+0

ありがとう@BhavinRamani :) –

+0

とても華麗です、ありがとう:) –

関連する問題