-
(NSAttributedString )getLocationStr:(NSString)locationString{
NSMutableAttributedString *text = [NSMutableAttributedString new];
NSTextAttachment *attch = [[NSTextAttachment alloc] init];
//定义图片内容及位置和大小
attch.image = [UIImage imageNamed:@"weiba_location_ly"];
attch.bounds = CGRectMake(8, -3, 12, 14);
//创建带有图片的富文本
NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch];
NSAttributedString *locationStr = [[NSAttributedString alloc] initWithString:locationString];
NSAttributedString *Str = [[NSAttributedString alloc] initWithString:@" "];[text appendAttributedString:string];
[text appendAttributedString:Str];
[text appendAttributedString:locationStr];
return text;
}
创建带有图片的富文本018-07-31
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 原文地址:http://blog.csdn.net/deft_mkjing/article/details/521...
- 一、关于AttributedString 在iOS开发过程中系统简单的封装工具已经不够我们使用,为了更好的开发,苹...