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"];
  • 相关阅读:
    Ubuntu 16.04远程登录服务器--ssh的安装和配置
    设置淘宝源
    shell 循环 read line
    apt-get update 报错 W: Unknown Multi-Arch type 'no' for package 'compiz-core'
    expdp dblink
    ubuntu apt-update NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
    listener.log文件过大导致oracle假死
    rsync_ssh
    ssh多主机
    elk大纲
  • 原文地址:https://www.cnblogs.com/shenhongbang/p/5430201.html
Copyright © 2011-2022 走看看