Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change UITextField's placeholder text color using Userattributes?

I want to change Place holder color from user attributes (interface builder) because i dont want to subclass my UITextfield etc... i searched on internet and found this "_placeholderLabel.textColor" Yes this works well Programmatically [self.tfEmail setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"]; but i want to use it in user attributes in interface builder.

like image 529
Hassan1214 Avatar asked Jan 16 '14 07:01

Hassan1214


2 Answers

Try removing '_',

Image

Works for me.

like image 88
Zeeshan Avatar answered Sep 20 '22 23:09

Zeeshan


Without USING USER ATTRIBUTES

 self.txtField.attributedPlaceholder = PlaceHolderAttributedString(@"ABCDEF");

where PlaceHolderAttributedString is a macro defined as

 #define PlaceHolderAttributedString(placeHolderText) [[NSAttributedString alloc] initWithString:placeHolderText attributes:@{NSForegroundColorAttributeName:ColorTextFieldPlaceHolder}]

USING USER ATTRIBUTES

 placeholderLabel.textColor 
like image 38
Tahir Iqbal Avatar answered Sep 20 '22 23:09

Tahir Iqbal