UITextField IOS7 not setting font color during input

I have some simple code that worked fine under iOS6. In a UITextField when the event editingDidBegin arrived I executed a simple piece of code that changed the color of the text that was entered:

textField.textColor = [UIColor redColor];

Although this code is executed, the text color does not change to red, but remains unchanged at its default color as the text is being entered.

If I call this method on editingDidEnd, the text is entered in the default color, but changes to red when editingDidEnd kicks off the same piece of code:

textField.textColor = [UIColor redColor];

It seems as though I can not change the textColor property when the textField is the first responder.

Any help here would be greatly appreciated.


You should do some subclassing for that

Here is a good solution that works both on ios6 and ios7 http://www.brightec.co.uk/blog/how-change-colour-uitextfields-placeholder-text-ios7-and-still-support-ios6

I found another way of accomplishing this. I used the UITextField delegate method and added the following code. Seems like my original method should have worked moving to IOS7, but this now works fine.

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    textField.textColor = [UIColor redColor];
    return YES;

[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];

This will change the place holder color of UITextField,

Need Your Help

Nothing happens when I do: python manage.py command

python django django-admin

I'm new to django and currently going through the main tutorial. Even though it was working earlier, when I do python manage.py runserver OR python manage.py -h OR with any other command, the shell...

mysql query using array result of another query

php mysql arrays mysqli

I have a simple query that finds cities that are within a certain distance of a given latitude and longitude.