码迷,mamicode.com
首页 > 其他好文 > 详细

遮罩 HUD 指示器 蒙板 弹窗

时间:2015-07-09 00:12:34      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:

遮罩 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

遮罩 HUD 指示器 蒙板 弹窗

标签:

原文地址:http://www.cnblogs.com/ShaoYinling/p/4631555.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!