-(NSAttributedString *)imagesWithimgName:(NSString* )imgName offsetY:(CGFloat)offsetY
{
NSTextAttachment * textAttachment = [[NSTextAttachment alloc]init];
UIImage * smileImage = [ UIImage imageNamed:imgName];
textAttachment.image = smileImage ;
textAttachment.bounds = CGRectMake(0, offsetY, smileImage.size.width, smileImage.size.height);
return [NSAttributedString attributedStringWithAttachment:textAttachment];
}
-(void)appendImgStr:(NSString* )imgName offsetY:(CGFloat)offsetY
{
[self appendAttributedString:[self imagesWithimgName:imgName offsetY:offsetY]];
}
图文混排之NSAttributedString
最新推荐文章于 2017-11-28 13:09:57 发布