這樣的效果
屏幕快照 2017-10-30 14.11.16.png
廢話不說,直接貼代碼
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"在線轉賬" message:balance preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"請輸入電話號碼";
textField.keyboardType = UIKeyboardTypePhonePad;
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"請輸入要轉賬的金額";
textField.keyboardType = UIKeyboardTypeDecimalPad;
}];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
UITextField *phone = alertController.textFields.firstObject;
UITextField *money = [alertController.textFields objectAtIndex:1];
if (phone.text.length != 11) {
[PublicMethod showAlert:self message:@"請輸入格式正確的電話號碼"];
} else if (money.text != nil){
// 進行你需要d
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:okAction];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:^{
}];