美文网首页
创建带有图片的富文本018-07-31

创建带有图片的富文本018-07-31

作者: 未来可期me | 来源:发表于2018-07-31 09:58 被阅读13次
    • (NSAttributedString )getLocationStr:(NSString)locationString{
      NSMutableAttributedString *text = [NSMutableAttributedString new];
      NSTextAttachment *attch = [[NSTextAttachment alloc] init];
      //定义图片内容及位置和大小
      attch.image = [UIImage imageNamed:@"weiba_location_ly"];
      attch.bounds = CGRectMake(8, -3, 12, 14);
      //创建带有图片的富文本
      NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch];
      NSAttributedString *locationStr = [[NSAttributedString alloc] initWithString:locationString];
      NSAttributedString *Str = [[NSAttributedString alloc] initWithString:@" "];

      [text appendAttributedString:string];
      [text appendAttributedString:Str];
      [text appendAttributedString:locationStr];
      return text;
      }

    相关文章

      网友评论

          本文标题:创建带有图片的富文本018-07-31

          本文链接:https://www.haomeiwen.com/subject/vfecvftx.html