UIAlertController

 UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:nilmessage:title preferredStyle:UIAlertControllerStyleAlert];

    

    /**设置 textField 的暗文 */

    [alertControlleraddTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) {

        textField.placeholder =@"密码";

        textField.secureTextEntry =YES;

    }];

    /**设置 alertController的按钮*/

    UIAlertAction *cancelAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];

    UIAlertAction *okAction = [UIAlertActionactionWithTitle:@"确认"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnull action) {

       UITextField *login = alertController.textFields.firstObject;

       if ([login.textisEqualToString:@"123"]) {

           NSLog(@"成功");

        }else{

           UIView * view = [[UIApplicationsharedApplication].windowslastObject];

            [selfshowMBProgressHUDWith:view labelText:@"密码错误,请重试"andHidenTime:1];

        }

    }];

    

    /**设置 UIAlertAction的字体颜色 */

    [cancelActionsetValue:NAVCOLORforKey:@"_titleTextColor"];

    [okActionsetValue:NAVCOLORforKey:@"_titleTextColor"];

    

    [alertControlleraddAction:cancelAction];

    [alertControlleraddAction:okAction];

    

    /**弹出 alertController */

    [selfpresentViewController:alertController animated:YEScompletion:nil];


你可能感兴趣的:(UIAlertController)