I have a subclass of UITextField
where I set the text color to be white. I am using this subclass for an email field and a password field.
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
self.clearButtonMode = UITextFieldViewModeWhileEditing;
self.layer.backgroundColor = [UIColor clearColor].CGColor;
self.textColor = [UIColor whiteColor];
[self setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
......
......
The password field has secureTextEntry
set to YES
, and when I first type in it the color is white as expected. Then, if I click the clear button, focus on the email field and then focus back on the password field and begin typing, the text is now black.
I'm not sure why it lost the color I set in my drawRect
override. If I try the same steps with the email field it stays white no matter how many times I clear and unfocus/refocus the field.
I'm guessing this has to do with the secure text entry. Any help in this area will be much appreciated. Thanks!