iOS 开发 NSString后面带个image(图文混排)
2020-10-26 本文已影响0人
小y想吃糖
如图所示:
【线上担保】 几个字是一个图片。
NSTextAttachment *attch = [[NSTextAttachment alloc] init];
attch.image = [UIImage imageNamed:@"kc_order_list_title_tag_on"];
attch.bounds =CGRectMake(0, -3,58,17);
NSAttributedString *imageString = [NSAttributedString attributedStringWithAttachment:attch];
NSMutableAttributedString *abs = [[NSMutableAttributedString alloc] initWithString:_labelTitle.text];
[abs appendAttributedString:imageString];
_labelTitle.attributedText= abs;