阅读 142

UILabel显示 图片+文字

    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;
复制代码
文章分类
iOS
文章标签