遮罩 HUD 指示器 蒙板 弹窗
2024-08-30 20:16:33
遮罩 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
最新文章
- 使用Nginx反向代理 让IIS和Tomcat等多个站点一起飞
- 第8章 Java类的三大特性之一:封装
- 利用ipython实现多线程
- 使用NHibernate(3)-- 用代码代替配置文件
- JVM的数据类型
- Linux按照CPU、内存、磁盘IO、网络性能监测
- android中设置Animation 动画效果
- thinkphp 区分大小写的文件存在判断
- 转:hadoop知识整理
- i++与++i哪个效率更高
- docker镜像导入导出
- 配置firewalld端口转发
- IntelliJ IDEA常用设置(一)
- Android开发——ListView使用技巧总结(一)
- Swift3 今日(TodayExtension)扩展图文笔记
- 20155217《网络对抗》Exp02 后门原理与实践
- 【Alpha】特殊情况通知
- HNOI2018毒瘤
- [转]C++结构体|类 内存对齐详解
- [转]如何使用VS 2013發布一個可以在Windows XP中獨立運行的可執行文件