I have a problem in a XIB. The color of my placeholder color is default gray in interface builder but when i run the app the color of the text i white, and I'cant see it because the background is white.
Does anyone have a solution to this?
I have a problem in a XIB. The color of my placeholder color is default gray in interface builder but when i run the app the color of the text i white, and I'cant see it because the background is white.
Does anyone have a solution to this?
You can override drawPlaceholderInRect:(CGRect)rect
as such to manually render the placeholder text in UITextField
- (void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor blueColor] setFill];
[[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]];
}
The above solution did not work for me, I used the following workaround.
[UILabel appearanceWhenContainedIn:[UITextField class], nil] setTextColor:[UIColor darkGrayColor]];
But then I got to know another bug, the above did the job but it also reset the color of all other labels to Default Black. Then I had to sub class the UILabel class and use my class in all other labels in my view.
Quick fix on the syntax:
[[UILabel appearanceWhenContainedIn:[UITextField class], nil] setTextColor:[UIColor darkGrayColor]];
© 2022 - 2024 — McMap. All rights reserved.
UITextField
? Say, for instance,CustomTextField
? – Aeronaut