zoukankan      html  css  js  c++  java
  • 个性化 UIAlertController

    系统的 UIAlertController 封装的很漂亮,用block代替之前 UIAlertView 的代理,用起来更方便的,但是其曝露出来的接口也不多如果要个性化一些东西,比如字体大小、颜色就不是很方便了,下面总结一下 UIAlertController 更改字体的方法,以作备忘:

    1、UIAlertController 的标题(Title)、和描述(Message) 可以更改字体的大小和颜色

    NSAttributedString *attTitle = [[NSAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:16], NSForegroundColorAttributeName : [UIColor colorWithHexstring:@"333333"]}];
        [alert setValue:attTitle forKey:@"attributedTitle"];
    NSAttributedString *attMessage = [[NSAttributedString alloc] initWithString:message attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:16], NSForegroundColorAttributeName : [UIColor colorWithHexstring:@"333333"]}];
            [alert setValue:attMessage forKey:@"attributedMessage"];

    这样可以设置 alert 的title,和 message 。注意会覆盖 alert 初始化时填写的值。

    2、UIAlertController 的按钮(action) 可以更改字体颜色,字体大小没找到怎么改

    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
    [sureAction setValue:[UIColor colorWithHexstring:@"18a74f"] forKey:@"titleTextColor"];
  • 相关阅读:
    Tensorflow CIFAR10 (二分类)
    2018年阿里巴巴重要开源项目汇总
    环境变量备份
    ubuntu Qt5 librealsense opencv
    ubuntu16.04 qt opencv3.4
    时间作为文件名
    ubuntu16.04 安装opencv3
    Visual studio 2015/2017 opencv3.4 kineck2.0 osg realsense配置
    开源监控系统整合Nagios+Cacti+Nconf详解
    nagios系列(八)之nagios通过nsclient监控windows主机
  • 原文地址:https://www.cnblogs.com/shenhongbang/p/5430201.html
Copyright © 2011-2022 走看看