IOS label加图片

 
    NSMutableAttributedString * attriStr = [[NSMutableAttributedString alloc] initWithString:_labelGrowthValue.text];
    
    /**
     添加图片到指定的位置
     */
    NSTextAttachment *attchImage = [[NSTextAttachment alloc] init];
    // 表情图片
    attchImage.image = [UIImage imageNamed:@"icon_chengzhangzhi"];
    // 设置图片大小
    attchImage.bounds = CGRectMake(0, 0, 15, 15);
    NSAttributedString *stringImage = [NSAttributedString attributedStringWithAttachment:attchImage];
    [attriStr insertAttributedString:stringImage atIndex:0];

    _labelGrowthValue.attributedText = attriStr;

你可能感兴趣的:(IOS label加图片)