一段图文混排代码(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;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容