zoukankan      html  css  js  c++  java
  • 第三十三篇、富文本 NSMutableAttributedString

    // 设置颜色等
      NSMutableDictionary *arrDic = [NSMutableDictionary dictionary];
      arrDic[NSForegroundColorAttributeName] = [UIColor purpleColor];
      arrDic[NSBackgroundColorAttributeName] = [UIColor greenColor];
      arrDic[NSKernAttributeName] = @10;
      arrDic[NSUnderlineStyleAttributeName] = @1;
    
      NSMutableAttributedString *attriOneStr = [[NSMutableAttributedString alloc]initWithString:@"来呀,快活呀,反正有大把时光" attributes:arrDic];
      self.oneLabel.attributedText = attriOneStr;
    
      // 简单的图文混排
      NSMutableAttributedString *arrTwoStr = [[NSMutableAttributedString alloc]init];
      NSMutableAttributedString *TwoChildStr = [[NSMutableAttributedString alloc]initWithString:@"你好啊"];
      [arrTwoStr appendAttributedString:TwoChildStr];
    
      NSTextAttachment *attachMent = [[NSTextAttachment alloc]init];
      attachMent.image = [UIImage imageNamed:@"2"];
      attachMent.bounds = CGRectMake(0, -5, 20, 20);
      NSAttributedString *picStr = [NSAttributedString attributedStringWithAttachment:attachMent];
      [arrTwoStr appendAttributedString:picStr];
    
      NSAttributedString *TwooStr = [[NSAttributedString alloc]initWithString:@"我是小菜鸟"];
      [arrTwoStr appendAttributedString:TwooStr];
      self.twoLabel.attributedText = arrTwoStr;
  • 相关阅读:
    函数调用时函数栈状态分析
    [Project Euler] Problem 51
    [Project Euler] Problem 52
    [Project Euler] Problem 49
    自己的路
    COBOL FILE STATUS(return code)
    SVN客户端使用手册
    堆栈在VBA中的实现
    一个月以来的实习总结
    OpenCVPython系列之图像腐蚀与膨胀
  • 原文地址:https://www.cnblogs.com/HJQ2016/p/5892499.html
Copyright © 2011-2022 走看看