1、图片放文字前面
NSMutableAttributedString*attri1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@" %@",langaugeString(@"voice", @"recordVoiceMemo")]];//录制语音
//NSTextAttachment可以将要插入的图片作为特殊字符处理
NSTextAttachment*attch1 = [[NSTextAttachment alloc]init];
//定义图片内容及位置和大小
attch1.image= [UIImage imageNamed:@"luyin"];
attch1.bounds=CGRectMake(0,-3,14,18.5);//图片的大小
//创建带有图片的富文本
NSAttributedString*string1 = [NSAttributedString attributedStringWithAttachment:attch1];
//将图片放在第一位
[attri1 insertAttributedString:string1 atIndex:0];
_lab_voice.attributedText= attri1;
2、图片放文字后面
- (NSMutableAttributedString *) imageAndTitle:(NSString *)str {
NSMutableAttributedString*attri1 = [[NSMutableAttributedString alloc]initWithString:str];//
//NSTextAttachment可以将要插入的图片作为特殊字符处理
NSTextAttachment*attch1 = [[NSTextAttachment alloc]init];
//定义图片内容及位置和大小
attch1.image= [UIImage imageNamed:@"photo_z bean"];
attch1.bounds=CGRectMake(0,0,18,17.5);//图片大小
//创建带有图片的富文本
NSAttributedString*string1 = [NSAttributedString attributedStringWithAttachment:attch1];
//将图片放最后
[attri1 appendAttributedString:string1];
return attri1;
}