I am trying to use the UIActionController in ios to display a text field, and I want to know how to change the border color of a field.
my code is:
- (void)showChangePasswordAlertView { UIAlertController *actionVC = [UIAlertController alertControllerWithTitle:@"" message:@"Change your password." preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { }]; [actionVC addAction:action]; action = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { }]; [actionVC addAction:action]; [actionVC addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = @"old password"; textField.borderStyle = UITextBorderStyleNone; textField.layer.borderColor = [UIColor redColor].CGColor; textField.layer.borderWidth = 1.0 ; textField.secureTextEntry = YES ; }]; [actionVC addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = @"new password"; textField.borderStyle = UITextBorderStyleNone; textField.secureTextEntry = YES ; }]; [actionVC addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = @"confirm new password"; textField.borderStyle = UITextBorderStyleNone; textField.secureTextEntry = YES ; }]; [self presentViewController:actionVC animated:YES completion:nil]; }
but the result:

Does any body know how to do this? Thanks.
uitextfield
monjer
source share