zoukankan      html  css  js  c++  java
  • UILabel设置字体不同颜色

    1 self.title = @"For iOS 6 & later";
    2 NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"];
    3 [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)];
    4 [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];
    5 [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];
    6 [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0, 5)];
    7 [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6, 12)];
    8 [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19, 6)];

    9 attrLabel.attributedText = str;

  • 相关阅读:
    WebAssembly学习(四):AssemblyScript
    Ramda
    React—生命周期
    网络拓扑图
    手机端的meta信息
    面试题
    Bootstrap路径导航
    Bootstrap 分页翻页
    Bootstrap栅格系统
    Bootstrap 屏幕类型
  • 原文地址:https://www.cnblogs.com/XHShare/p/5207464.html
Copyright © 2011-2022 走看看