+(NSMutableAttributedString*)mixedTextContent:(NSString*)contentString image:(NSString*)imageNameString index:(NSInteger)index font:(UIFont*)fontsize
{
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
[stringappendAttributedString:[[NSMutableAttributedString alloc] initWithString:contentString]];
NSTextAttachment *attach = [[NSTextAttachment alloc] init];
attach.image= [UIImageimageNamed:imageNameString];
//计算图片大小,与文字同高,按比例设置宽度
CGFloatimgH = fontsize.pointSize;
CGFloatimgW = (attach.image.size.width/ attach.image.size.height) * imgH;
//计算文字padding-top ,使图片垂直居中
CGFloattextPaddingTop = (fontsize.lineHeight- fontsize.pointSize) /2;
attach.bounds=CGRectMake(0, -textPaddingTop , imgW, imgH);
NSAttributedString *attachString = [NSAttributedString attributedStringWithAttachment:attach];
[stringinsertAttributedString:attachStringatIndex:index];
returnstring;
}