一段图文混排代码(KDA)

- (NSMutableAttributedString*)KDAStringByRecordDetail:(RecordDetail*)recordDetail{

NSMutableAttributedString*string = [[NSMutableAttributedStringalloc]initWithString:@""];

//创建图片图片附件

NSDictionary*attributeDict = [NSDictionarydictionaryWithObjectsAndKeys:

[UIFontsystemFontOfSize:14.0],NSFontAttributeName,

RGBA(208,255,255,1),NSForegroundColorAttributeName,nil];

NSTextAttachment*attachSolk = [[NSTextAttachmentalloc]init];

attachSolk.image= [UIImageimageNamed:@"game_kill_pic"];

attachSolk.bounds=CGRectMake(0, -3,15,15);

NSAttributedString*attachStringSolk = [NSAttributedStringattributedStringWithAttachment:attachSolk];

[stringappendAttributedString:attachStringSolk];

NSAttributedString*attributedStringSolk = [[NSAttributedStringalloc]initWithString:[NSStringstringWithFormat:@"%@",recordDetail.solkDesc]attributes:attributeDict];

[stringappendAttributedString:attributedStringSolk];

NSTextAttachment*attachAsst = [[NSTextAttachmentalloc]init];

attachAsst.image= [UIImageimageNamed:@"game_assist_pic"];

attachAsst.bounds=CGRectMake(0, -3,15,15);

NSAttributedString*attachStringAsst = [NSAttributedStringattributedStringWithAttachment:attachAsst];

[stringappendAttributedString:attachStringAsst];

NSAttributedString*attributedStringAsst = [[NSAttributedStringalloc]initWithString:[NSStringstringWithFormat:@"%@",recordDetail.asstDesc]attributes:attributeDict];

[stringappendAttributedString:attributedStringAsst];

NSTextAttachment*attachDths = [[NSTextAttachmentalloc]init];

attachDths.image= [UIImageimageNamed:@"game_dead_pic"];

attachDths.bounds=CGRectMake(0, -3,15,15);

NSAttributedString*attachStringDths = [NSAttributedStringattributedStringWithAttachment:attachDths];

[stringappendAttributedString:attachStringDths];

NSAttributedString*attributedStringDths = [[NSAttributedStringalloc]initWithString:[NSStringstringWithFormat:@"%@",recordDetail.dthsDesc]attributes:attributeDict];

[stringappendAttributedString:attributedStringDths];

returnstring;

}

你可能感兴趣的:(一段图文混排代码(KDA))