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.
Try removing '_',
Works for me.
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
在swift中:
one_textfield.setValue(UIColor.redColor(), forKeyPath: "_placeholderLabel.textColor")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.