UILabel *label = [[UILabel alloc]init]; label.numberOfLines = 0; [self.view addSubview:label]; label.backgroundColor = [UIColor grayColor]; label.textColor = [UIColor redColor]; NSMutableAttributedString *attisstr = [[NSMutableAttributedString alloc]initWithString:@"版权声明:本文为博主原创文章,未经博主允许不得转载。 http://www.cnblogs.com/shenlaiyaoshi/版权声明:本文为博主原创文章,未经博主允许不得转载。 http://www.cnblogs.com/shenlaiyaoshi/"]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; dict[NSFontAttributeName] = [UIFont systemFontOfSize:15]; NSMutableParagraphStyle *parstype = [[NSMutableParagraphStyle alloc]init]; parstype.lineSpacing = 15; dict[NSParagraphStyleAttributeName] = parstype; NSTextAttachment *attachment = [[NSTextAttachment alloc]init]; attachment.image = [UIImage imageNamed:@"1533291758"]; attachment.bounds= CGRectMake(0, -17, 40, 40); NSAttributedString *stringsimage = [NSAttributedString attributedStringWithAttachment:attachment];; [attisstr insertAttributedString:stringsimage atIndex:3]; dict[NSAttachmentAttributeName] = attachment; label.attributedText = [[NSAttributedString alloc]initWithString:[attisstr string] attributes:dict]; [label sizeToFit];