自定义alert弹框
/**************** UIAlertControllerStyleAlert *************************/
/*创建一个 可以自定义文字颜色和字体大小的IAlertView*/
NSString *message = @"开通失败,请再次开通或者联系客服";
NSString *title = @"400-8591-200";
NSString *leftActionStr = @"呼叫";
NSString *rightActionStr = @"继续开通";
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
//改变title的大小和颜色
NSMutableAttributedString *titleAtt = [[NSMutableAttributedString alloc] initWithString:title];
[titleAtt addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:(/)*KWidth_Scale] range:NSMakeRange(, title.length)];
[titleAtt addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x00abea) range:NSMakeRange(, title.length)];
[alertController setValue:titleAtt forKey:@"attributedTitle"];
//改变message的大小和颜色
NSMutableAttributedString *messageAtt = [[NSMutableAttributedString alloc] initWithString:message];
[messageAtt addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:(/)*KWidth_Scale] range:NSMakeRange(, message.length)];
[messageAtt addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x666666) range:NSMakeRange(, message.length)];
[alertController setValue:messageAtt forKey:@"attributedMessage"]; UIAlertAction *alertActionCall = [UIAlertAction actionWithTitle:leftActionStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://400-8591-200"]];
}];
[alertController addAction:alertActionCall];
[alertActionCall setValue:UIColorFromRGB(0x00abea) forKey:@"titleTextColor"];
kWeakSelf(weakSelf);
UIAlertAction *alertActionContinue = [UIAlertAction actionWithTitle:rightActionStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[weakSelf oprDrugStoreStatu:@""];
}];
[alertController addAction:alertActionContinue];
[alertActionContinue setValue:[UIColor blackColor] forKey:@"titleTextColor"];
[self presentViewController:alertController animated:YES completion:nil]; /**************** UIAlertControllerStyleActionSheet *************************/
NSString *title = [NSString stringWithFormat:@"将患者\"%@\"删除,同时删除与该联系人的聊天记录", self.user.patientName];
UIAlertController *alertSheet = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[cancel setValue:UIColorFromRGB(0x666666) forKey:@"titleTextColor"];
[alertSheet addAction:cancel]; UIAlertAction *certain = [UIAlertAction actionWithTitle:@"删除联系人" style:UIAlertActionStyleDestructive handler:
^(UIAlertAction * _Nonnull action) {
NSLog(@"执行删除操作,这里应该接着请求删除接口......");
}];
[alertSheet addAction:certain];
[self presentViewController:alertSheet animated:YES completion:nil];
自定义alert弹框的更多相关文章
- JavaScript实现自定义alert弹框
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAh0AAAFkCAYAAACEpYlzAAAfj0lEQVR4nO3dC5BddZ0n8F93pxOQCO
- 自定义alert弹框,title不显示域名
问题: 系统默认的alert弹框的title会默认显示网页域名 解决办法: (修改弹框样式) (function() { window.alert = function(name) { $(" ...
- 自定义alert弹框,title不显示域名(重写alert)
问题: 系统默认的alert弹框的title会默认显示网页域名 解决办法: (修改弹框样式) (function() { window.alert = function(name) { $(" ...
- [转]自定义alert弹框,title不显示域名
//(仅去掉网址) (function(){ window.alert = function(name){ var iframe = document.createElement("IFRA ...
- CodePush自定义更新弹框及下载进度条
CodePush 热更新之自定义更新弹框及下载进度 先来几张弹框效果图 非强制更新场景 image 强制更新场景 image 更新包下载进度效果 image 核心代码 这里的热更新Modal框,是封装 ...
- selenium对Alert弹框的多种处理
Alert弹框是一个很烦人的控件,因为当前页面如果弹出了该弹框,你必须要处理它,不然你就不能操作页面的其它元素,下面我列出了alert弹框在多种场景下的处理办法. 明确知道系统哪个地方会弹alert ...
- python工具 - alert弹框输出姓名年龄、求和
使用python自带的tkinter库进行GUI编程,完成两个功能: (1)要求用户输入姓名和年龄然后打印出来 (2)要求用户输入一个数字,然后计算1到该数字之间的和 代码部分: # 导入tkinte ...
- 操作JavaScript的Alert弹框
@Testpublic void testHandleAlert(){ WebElement button =driver.findElement(By.xpath("input" ...
- 仿写confirm和alert弹框
在工作中,我们常常会遇到原生的样式感觉比较丑,又和我们做的项目风格不搭.于是就有了仿写原生一些组件的念头,今天我就带大家仿写一下confirm和alert样式都可以自己修改. 有些的不好的地方请指出来 ...
随机推荐
- install pytorch
1. install and update pip3 2. install numpy and scipy 3. install pytorch
- centos7 卸载home 扩大root空间
=============================================== 2017/11/1_第1次修改 ccb_warlock == ...
- 防盗链与token运用
为什么要防盗链? 例如手机/PC应用,如果有人知道你的api地址,和应用格式,那么他人就可以利用这个接口进行盗链:盗取/盗用里面的数据. 防盗链特性: 1.因为是非开放性的,所以所有的接口都是封闭的, ...
- js 向form表单中插入数据
var newElement = document.createElement("input"); var nowtime=year+""+month+day+ ...
- popupwindow那些坑
1. new PopupWindow(vw, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 如果 ...
- 多行文字水平垂直居中在div
<BODY> <div class="box"> <h3>1.单行文字居中</h3> <!--设置行高来实现- ...
- sublime自动保存(失去焦点自动保存)
sublime是轻量的编辑器,经常用sublime编辑器来做一些小例子,使用起来很方便. 在使用sublime的时候需要不断的 ctrl + s 保存代码,才能看到效果. 这样的操作很繁琐,保存的多了 ...
- September,开启一个新的征程!
寻找梦里的未来笑对现实的无奈不能后退的时候不再傍徨的时候永远向前 路...一直都在
- WPF自定义Window样式(2)
1. 引言 在上一篇中,介绍了如何建立自定义窗体.接下来,我们需要考虑将该自定义窗体基类放到类库中去,只有放到类库中,我们才能在其他地方去方便的引用该基类. 2. 创建类库 接上一篇的项目,先添加一个 ...
- 老版VC++线程池
在一般的设计中,当需要一个线程时,就创建一个,但是当线程过多时可能会影响系统的整体效率,这个性能的下降主要体现在:当线程过多时在线程间来回切换需要花费时间,而频繁的创建和销毁线程也需要花费额外的机器指 ...