2014-12-05 12 views
7

मैं ios में UIActionController उपयोग करने के लिए पाठ फ़ील्ड को दिखाने के लिए प्रयास करें, और मुझे पता है कि कैसे पाठ फ़ील्ड सीमा रंग बदलना चाहते हैं पाठ फ़ील्ड सीमा रंग बदलने के लिए।कैसे UIAlertController

मेरी कोड है:

- (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]; 
} 

लेकिन परिणाम है:

enter image description here

शरीर के किसी भी जानते हैं कि कैसे करना है? धन्यवाद।

+1

आप हल किया मुसीबत? –

उत्तर

0

यह एक सा hacky है, लेकिन यह निश्चित रूप से (आईओएस 8.3 पर परीक्षण) काम करता है:

UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert" 
                   message:@"This is an alert." 
                 preferredStyle:UIAlertControllerStyleAlert]; 

[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) { 

    textField.placeholder = @"This is my placeholder"; 
    [[textField superview] superview].backgroundColor = [UIColor redColor]; 

}]; 
+0

इस उत्तर 9.x में मेरे लिए काम नहीं कर रहा है। – Hima

0

यह hacky भी

शो UIAletController के बाद बताया गया है:

viewController.present(alert, animated: true, completion: nil) 

यह कोड जोड़ें:

YOUR_ALERT_CONTROLLER.textFields.forEach { 
    if let views = $0.superview?.superview?.subviews { 
     for case let visualView as UIVisualEffectView in views { 
      visualView.contentView.subviews.first?.backgroundColor = CURRENT_COLOR 
     } 
     } 
    } 
संबंधित मुद्दे