zoukankan      html  css  js  c++  java
  • ios

    • 代码
    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
        
        UIAlertController * alertVc = [UIAlertController alertControllerWithTitle:@"立即锁" message:@"设定后车辆被立即锁定" preferredStyle:UIAlertControllerStyleAlert];
        NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:@"立即锁"];
    //设置标题颜色
        [alertControllerStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 3)];
        [alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, 3)];
    //通过kvc赋值
        [alertVc setValue:alertControllerStr forKey:@"attributedTitle"];
    //设置标题中的message颜色
        NSMutableAttributedString *alertControllerMessageStr = [[NSMutableAttributedString alloc] initWithString:@"设定后车辆被立即锁定"];
        [alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, 10)];
        [alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 10)];
    //通过kvc赋值
        [alertVc setValue:alertControllerMessageStr forKey:@"attributedMessage"];
        UIAlertAction * actConfirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        UIAlertAction * actCan = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
    //设置按钮颜色
        [actCan setValue:[UIColor blackColor] forKey:@"titleTextColor"];
        [alertVc addAction:actCan];
        [alertVc addAction:actConfirm];
        [self presentViewController:alertVc animated:YES completion:^{
        }];
    }
    

    总体来讲,弹框标题以及标题下方提示信息通过创建富文本来实现修改字体颜色,以及改变大小,最后通过kvc进行赋值实现最终效果.

    • 效果
  • 相关阅读:
    go语言基础学习
    VBA汇总同目录下的所有工作簿数据到另一个工作簿,并进行统计
    彻底关闭win10后台同步数据(转自技术社区)
    在WIN10上安装ESXI-Comstomer (转自技术社区)
    squid代理允许FTP访问设置
    Powershell 脚本判断制定路径下文件是否存在(来源于网络-转载)
    Python集合(set)类型的操作 (转)
    python3.5.2中文字符乱码问题解决
    Debian 中文环境设置
    Python 列表推导实例
  • 原文地址:https://www.cnblogs.com/adampei-bobo/p/6993623.html
Copyright © 2011-2022 走看看