UIImage *image = [UIImage create]; NSTextAttachment *attch = [[NSTextAttachment alloc] init]; attch.image = image; NSAttributedString *imageStr = [NSAttributedString attributedStringWithAttachment:attch]; NSString *text = @""; NSDictionary * attrDict = @ {NSFontAttributeName: [UIFont systemFontOfSize: 15.0], NSForegroundColorAttributeName: UIColor.blackColor} NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:text attributes:attrDict]; [attri insertAttributedString:string atIndex:0]; UILabel *label = [UILabel new]; label.attributedText = attri;Copy the code