zoukankan      html  css  js  c++  java
  • UILabel图文混排显示图片和文字

    //传入文字 自动图片放在左边文字紧接着后排排布
    -(void)setAttrDetailLabelWithTitle:(NSString *)title
    {
        
        NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] init];
        // 添加表情
        NSTextAttachment *attch = [[NSTextAttachment alloc] init];
        // 表情图片
        UIImage *image =[UIImage imageNamed:@"zp"];
            image = [UIImage imageWithCGImage:image.CGImage scale:2 orientation:UIImageOrientationUp];
        
        attch.image = image;
        
        // 设置图片大小 和 微调图片的位置
        attch.bounds = CGRectMake(0, -2, image.size.width, image.size.height);
        
        // 创建带有图片的富文本
        NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch];
        [attri appendAttributedString:string];
        
        [attri appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
    
        [attri appendAttributedString:[[NSAttributedString alloc] initWithString:title]];
        
        // 用label的attributedText属性来使用富文本
        self.despLabel.attributedText = attri;
    }
    
    
    
  • 相关阅读:
    导出数据到Excel文件
    百度地图
    Web报表-RDLC报表的使用
    web开发经验—MVC 图表Chart
    数据库面试题
    滑块插件jRange的使用
    matplotlib绘图使用数据
    JS面向对象之封装
    如何使用Animate.css插件库
    圣杯布局,双飞翼布局
  • 原文地址:https://www.cnblogs.com/qqcc1388/p/6709471.html
Copyright © 2011-2022 走看看