自定义UIAlertController
来源:互联网 发布:linux 时区 -0400 编辑:程序博客网 时间:2024/05/20 11:19
最近写了一个自定义弹框,模仿系统UIAlertController,记录一下。
对于弹框,很多情况下还是习惯于写个UIView,但是系统都已经抛弃UIAlertView了,对UIAlertController,内容可能又不符合自己的需求,这。。。好吧,写一个吧。
ok,咱需要一个控制器,MineAlertController,继承自UIViewController,需要一个初始化方法:
+(MineAlertController *)alertWithTitle:(NSString *)title message:(NSString *)message handle:(void (^)())handle;
之所以用类方法创建,是因为我们需要对这个控制器做一些处理,至于参数,根据自己需要调整吧,好了,到这里,重点来了,弹出模式呢?
找找控制器的modalPresentationStyle,有个UIModalPresentationOverCurrentContext,做什么的呢,字面意思就是透过当前上下文,这就是我们需要的,浮在当前控制器之上。
+(MineAlertController *)alertWithTitle:(NSString *)title message:(NSString *)message handle:(void (^)())handle{
MineAlertController *controller = [[MineAlertController alloc] init];
contriller.title = title;
...
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
//主要是这三句
controller.definesPresentationContext =YES;
controller.providesPresentationContextTransitionStyle =YES;
controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
return controller;
}
剩下的就是控制器显示的内容样式了,根据需要写了。
- 自定义UIAlertController
- 自定义UIAlertController
- iOS开发--自定义UIAlertController
- Xamarin.IOS UIAlertController 自定义字体
- UIAlertController的使用及其自定义
- iOS7以上系统自定义UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIalertController
- UIAlertController
- UIalertController
- UIAlertController
- UIAlertController
- UIAlertController
- UIAlertController
- Codeforces 876F High Cry【逆向思维】
- Android题目笔记(二)
- 最新用友企业管理软件ERP T6 V7.0免狗破解
- 微信开发内置浏览器JS自动关闭当前页面回到微信对话窗口
- 谈谈MySQL水平扩展--分库分表
- 自定义UIAlertController
- MySQL 5.7以上 root用户默认密码问题
- 低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端
- 【1543】冒泡排序
- 前端js面试技巧(1)——js基础部分
- 堆栈的基本功能模板
- 区块链是什么,如何简单易懂地介绍区块链
- 用命令行创建AEM项目
- 一个tomcat部署多个应用,有几个JVM?