图文混排的方法:
NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:contentString]];
//图文混排
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = [UIImage imageNamed:imageString];
textAttachment.bounds = CGRectMake(0, -4, 25, 15);
// 用textAttachment生成属性字符串
NSAttributedString *attachmentAttrStr = [NSAttributedString attributedStringWithAttachment:textAttachment];
// 属性字符串插入到目标字符串
[AttributedStr insertAttributedString:attachmentAttrStr atIndex:0];
myLabel.attributedText = AttributedStr;
其中contentString就是字符串的内容
imageString是本地图片
给文字添加中划线
NSString *textStr = [NSString stringWithFormat:@"¥14.00"];
//中划线
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:textStr attributes:attribtDic];
// 赋值
myLabel.attributedText = attribtStr;