UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"請輸入支付密碼" preferredStyle:UIAlertControllerStyleAlert];
//增加取消按鈕;
[alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
//增加確定按鈕;
[alertController addAction:[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//獲取第1個輸入框;
UITextField *userNameTextField = alertController.textFields.firstObject;
NSLog(@"支付密碼 = %@",userNameTextField.text);
}]];
//定義第一個輸入框;
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"請輸入支付密碼";
textField.secureTextEntry = YES;
}];
[self presentViewController:alertController animated:true completion:nil];