iOS Label标题有占位图片

 NSMutableAttributedString *str=[[NSMutableAttributedString alloc] initWithString:@"

2015年互联网发生的大事件的影响因素?2015年互联网发生的大事件的影响因素??

" attributes:nil];

    

    NSTextAttachment *attachment=[[NSTextAttachment alloc] initWithData:nil ofType:nil];

    UIImage *img=[UIImage imageNamed:@"qrcode.png"];

    attachment.image=img;

    attachment.bounds=CGRectMake(0, -10, 20, 20);

    NSAttributedString *text=[NSAttributedString attributedStringWithAttachment:attachment];

    //设置从第几个字符开始插入

    [str insertAttributedString:text atIndex:0];

    self.textView.attributedText=str;

你可能感兴趣的:(iOS Label标题有占位图片)