zoukankan      html  css  js  c++  java
  • 给属性字符串添加下划线

     NSString *text = @"Privacy Policy.";

        NSMutableAttributedString * attributedText = [[NSMutableAttributedString alloc] initWithString: text];

        NSRange range = NSMakeRange(0, [attributedText length]);

        [attributedText beginEditing];

           // next make the text appear with an underline

        NSRange underLineRange = range;

        range.length -= 1;

        [attributedText addAttribute: NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSSingleUnderlineStyle] range:underLineRange];

        [attributedText addAttribute:NSFontAttributeName value:PRDefaultFontWithSize(NO, 12) range:range];

        [attributedText addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithDeviceRed:237/255.0 green:187/255.0 blue:112/255.0 alpha:1] range:underLineRange];

        [attributedText addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithDeviceRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1]range:NSMakeRange([attributedText length]-1, 1)];

        

        [attributedText endEditing];

  • 相关阅读:
    GHOST CMS
    某小姑娘治疗案
    关于ssl证书的一些知识
    Hbuiler中常用的快捷键
    跌落损任胸胁案
    老年脑梗案
    Centos7安装完成后设定基本的网络配置
    Centos7下的文件压缩
    在centos7上用docker安装宝塔面板
    右手中指一侧麻木案
  • 原文地址:https://www.cnblogs.com/PJXWang/p/5302415.html
Copyright © 2011-2022 走看看