Check in text box: highlighted red frame, iPhone

There are several applications in which checked text fields are highlighted in red when the user enters incorrect information into it.

I want to use this validation and highlighting technique on the iPhone too. How can i do this?

+7
source share
2 answers

you can check the text by setting the UITextField delegate to your controller, and then do something like:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range { [self validateInput]; // Your method to check what the user is writting return YES; } 

And in your "validateInput", change the background image if the validation fails.

+8
source

Change the border color of a TextField using QuartzCore

 #import <QuartzCore/QuartzCore.h> [...] textField.layer.borderWidth = 1.0f; textField.layer.borderColor = [[UIColor redColor] CGColor]; 

with rounded corners

 textField.layer.cornerRadius = 5; textField.clipsToBounds = YES; 
+23
source

All Articles