美文网首页
label使用富文本添加图片

label使用富文本添加图片

作者: guoguojianshu | 来源:发表于2020-10-12 16:15 被阅读0次
 NSString *words = [NSString stringWithFormat:@" %ld",XSModel.schemeIntegral];
    NSMutableAttributedString *strAtt = [[NSMutableAttributedString alloc] initWithString:words attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15*XSWIDESCALE]}];
    NSTextAttachment *attatch = [[NSTextAttachment alloc] initWithData:nil ofType:nil];
    attatch.bounds = CGRectMake(0, 0, 14, 14);
    attatch.image = [UIImage imageNamed:@"zuanshi"];
    
    NSAttributedString *string8 = [NSAttributedString attributedStringWithAttachment:attatch];
    [strAtt insertAttributedString:string8 atIndex:0];
    self.XSMiaoBiLabel.attributedText = strAtt;
    self.XSPriceLabel.text = [NSString stringWithFormat:@"%@",XSModel.schemeName];

相关文章

网友评论

      本文标题:label使用富文本添加图片

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