遮罩 HUD 指示器 蒙板 弹窗

遮罩 HUD 指示器 蒙板 弹窗

UIAlertView的使用<代理方法处理按钮点击>

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"警告" message:@"是否要删除它?" delegate:self cancelButtonTitle:@"是" otherButtonTitles:@"否", nil];
//加登录框
    alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    [alertView show];

UIActionSheet的使用 <代理方法处理按钮点击>

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"警告:确定要删除它?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"随便", nil];

    [sheet showInView:self.view];

UIAlertController的使用:UIAlertControllerStyleActionSheet

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"警告" message:@"确定要删除它?" preferredStyle:UIAlertControllerStyleActionSheet];

    // 添加按钮 <UIAlertActionStyleDestructive>
    UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        NSLog(@"点击了【确定】按钮");
    }];
    [alertController addAction:sure];

    [alertController addAction:[UIAlertAction actionWithTitle:@"随便1" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSLog(@"点击了【随便1】按钮");
    }]];

    [alertController addAction:[UIAlertAction actionWithTitle:@"随便2" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSLog(@"点击了【随便2】按钮");
    }]];

    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"点击了【取消】按钮");
    }]];

    // 在当前控制器上面弹出另一个控制器:alertController  显示
    [self presentViewController:alertController animated:YES completion:nil];

UIAlertController的使用:UIAlertControllerStyleAlert<一>

 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"警告" message:@"message:确定?" preferredStyle:UIAlertControllerStyleAlert];

    // 添加按钮
    UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        NSLog(@"点击了【确定】按钮");
    }];
    [alertController addAction:sure];

    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"点击了【取消】按钮");
    }]];

    [alertController addAction:[UIAlertAction actionWithTitle:@"按钮" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSLog(@"点击了【按钮】按钮");
    }]];

    // 还可以添加文本框
    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        textField.textColor = [UIColor redColor];
        textField.secureTextEntry = YES; // 暗文
        textField.placeholder = @"请输入密码";
    }];

    // 在当前控制器上面弹出另一个控制器:alertController
    [self presentViewController:alertController animated:YES completion:nil];

UIAlertController的使用:UIAlertControllerStyleAlert<二>

 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"警告" message:@"message:确定?" preferredStyle:UIAlertControllerStyleAlert];

    // 添加按钮
    UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        NSLog(@"点击了【确定】按钮");
    }];
    [alertController addAction:sure];

    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"点击了【取消】按钮");
    }]];

    // 在当前控制器上面弹出另一个控制器:alertController
    [self presentViewController:alertController animated:YES completion:nil];

介绍框架<一> SVProgressHUD

// 下面这些消息需要主动调用dismiss方法来隐藏
    [SVProgressHUD show];
    [SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack]; // 增加灰色蒙板
    [SVProgressHUD showWithStatus:@"正在加载中..."];//下面添加提醒文字
    // 延迟2秒后 取消显示
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [SVProgressHUD dismiss];
    });


    // 下面这些消息会自动消失
//    [SVProgressHUD showInfoWithStatus:@"数据加载完毕!"];
//    [SVProgressHUD showSuccessWithStatus:@"成功加载到4条新数据!"];
//    [SVProgressHUD showErrorWithStatus:@"网络错误,请稍等!"];

    // 延迟2秒后做一些事情
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        [SVProgressHUD dismiss];
//    });
//   [SVProgressHUD showProgress:progress status:[NSString stringWithFormat:@"已下载%.0f%%", progress * 100]];

另一框架 MBProgressHUD

posted @ 2015-07-08 22:27  ShaoYL  阅读(706)  评论(0编辑  收藏  举报