zoukankan      html  css  js  c++  java
  • iOS开发实现Label中多颜色多字体

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

        label.textColor = wordGaryColor;  //未专门设置的字体颜色

        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"公司简介:发挥收到后即可圣诞节快发吧士大夫深刻的房价高速度开放和山东矿机山东科技楼粉红是大家分工"];

        [str addAttribute:NSForegroundColorAttributeName value:commonColor range:NSMakeRange(0,5)];

       [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];
       [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];
       [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:19] range:NSMakeRange(0, 5)];
       [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6, 12)];
       [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19, 6)];

        label.attributedText = str;

        [self.view addSubview:label];

  • 相关阅读:
    洛谷P1330 封锁阳光大学
    洛谷P1341 无序字母对
    Bzoj1059 [ZJOI2007]矩阵游戏
    POJ2337 Catenyms
    Bzoj2342 [Shoi2011]双倍回文
    Bzoj1009 [HNOI2008]GT考试
    Bzoj3670 [Noi2014]动物园
    POJ2406 Power Strings
    POJ 2752 Seek the Name, Seek the Fame
    POJ3522 Slim Span
  • 原文地址:https://www.cnblogs.com/yyt-hehe-yyt/p/5161209.html
Copyright © 2011-2022 走看看