UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Password"
message:@"Please enter your password"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK",nil];
[alertView setAlertViewStyle:UIAlertViewStyleSecureTextInput];
[alertView show];
AlertViewStyle:
typedef NS_ENUM(NSInteger, UIAlertViewStyle) {
UIAlertViewStyleDefault = 0,
UIAlertViewStyleSecureTextInput,
UIAlertViewStylePlainTextInput,
UIAlertViewStyleLoginAndPasswordInput
};
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
UITextField *tf = [alertView textFieldAtIndex:0];
NSLog(@"%@",tf.text);
}
总之棒棒的