zoukankan      html  css  js  c++  java
  • iOS 给UILabel文字加下划线

    摘自:http://blog.sina.com.cn/s/blog_6cd380c10101b6hn.html

    //带下划线的“注” NSMutableAttributedString可变的属性字符串,添加下划线属性

     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 300, 100)];

        label.backgroundColor = [UIColor redColor];
        label.numberOfLines = 3;

        label.adjustsFontSizeToFitWidth = YES;


        NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"

    @"注:本工具测试结果为一周内平均每天盐的摄入量;问题中涉及的食物均以一人份为准;本软件更适用于成人;建议您及您的家人使用低钠盐"

    "]];
        NSRange contentRange = {0,[content length]};
        [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
        
        label.attributedText = content;
        [self.view addSubview:label];

  • 相关阅读:
    Alpha冲刺第一天
    团队项目-需求分析
    设计模式第二次作业
    设计模式第一次作业
    冲刺合集
    冲刺NO.12
    项目测试
    冲刺NO.11
    冲刺NO.9
    冲刺NO.10
  • 原文地址:https://www.cnblogs.com/lrr0618/p/5227975.html
Copyright © 2011-2022 走看看