zoukankan      html  css  js  c++  java
  • 自定义alert弹框

     1 /**************** UIAlertControllerStyleAlert *************************/
     2 /*创建一个 可以自定义文字颜色和字体大小的IAlertView*/
     3 NSString *message = @"开通失败,请再次开通或者联系客服";
     4 NSString *title = @"400-8591-200";
     5 NSString *leftActionStr = @"呼叫";
     6 NSString *rightActionStr = @"继续开通";
     7 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
     8 //改变title的大小和颜色
     9 NSMutableAttributedString *titleAtt = [[NSMutableAttributedString alloc] initWithString:title];
    10 [titleAtt addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:(36/2)*KWidth_Scale] range:NSMakeRange(0, title.length)];
    11 [titleAtt addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x00abea) range:NSMakeRange(0, title.length)];
    12 [alertController setValue:titleAtt forKey:@"attributedTitle"];
    13 //改变message的大小和颜色
    14 NSMutableAttributedString *messageAtt = [[NSMutableAttributedString alloc] initWithString:message];
    15 [messageAtt addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:(24/2)*KWidth_Scale] range:NSMakeRange(0, message.length)];
    16 [messageAtt addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x666666) range:NSMakeRange(0, message.length)];
    17 [alertController setValue:messageAtt forKey:@"attributedMessage"];
    18 
    19 UIAlertAction *alertActionCall = [UIAlertAction actionWithTitle:leftActionStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    20     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://400-8591-200"]];
    21 }];
    22 [alertController addAction:alertActionCall];
    23 [alertActionCall setValue:UIColorFromRGB(0x00abea) forKey:@"titleTextColor"];
    24 kWeakSelf(weakSelf);
    25 UIAlertAction *alertActionContinue = [UIAlertAction actionWithTitle:rightActionStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    26     [weakSelf oprDrugStoreStatu:@"0"];
    27 }];
    28 [alertController addAction:alertActionContinue];
    29 [alertActionContinue setValue:[UIColor blackColor] forKey:@"titleTextColor"];
    30 [self presentViewController:alertController animated:YES completion:nil];
    31 
    32 
    33 
    34 
    35 /**************** UIAlertControllerStyleActionSheet *************************/
    36 NSString *title = [NSString stringWithFormat:@"将患者"%@"删除,同时删除与该联系人的聊天记录", self.user.patientName];
    37 UIAlertController *alertSheet = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    38 
    39 UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    40 [cancel setValue:UIColorFromRGB(0x666666) forKey:@"titleTextColor"];
    41 [alertSheet addAction:cancel];
    42 
    43 UIAlertAction *certain = [UIAlertAction actionWithTitle:@"删除联系人" style:UIAlertActionStyleDestructive handler:
    44                           ^(UIAlertAction * _Nonnull action) {
    45                               NSLog(@"执行删除操作,这里应该接着请求删除接口......");
    46                           }];
    47 [alertSheet addAction:certain];
    48 [self presentViewController:alertSheet animated:YES completion:nil];
  • 相关阅读:
    nginx(二)----ubuntu14.04下启动或重启和关闭nginx
    nginx(一)----ubuntu14.04下安装nginx
    ubuntu安装和查看已安装
    《太阳照常升起》
    [原]Jenkins(十四)---jenkins示例:admin管理所有项目,新建用户只能看部分项目
    第十二节:Nginx的简介、三种轮询配置方式、以及解决微服务架构负载均衡问题
    第一节:CDN、SLB、DNS(4层和7层)、IOT
    第三十节:Asp.Net Core中JWT刷新Token解决方案
    第六节:秒杀业务/超卖的几种解决思路
    第五节: Redis架构演变历程和cluster集群模式架构的搭建
  • 原文地址:https://www.cnblogs.com/jingxin1992/p/7700983.html
Copyright © 2011-2022 走看看