zoukankan      html  css  js  c++  java
  • iOS --有行距的图文混排

    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];

     

  • 相关阅读:
    Ubuntu修改root默认密码
    2012年总结
    阿朵,网上传得沸沸扬扬,我们还是听听她的歌吧!
    人力资源开发网站
    关于ant
    ObjectSpaces
    firefox plugs
    xpi插件的安装
    年关
    https的资源
  • 原文地址:https://www.cnblogs.com/shenlaiyaoshi/p/9465076.html
Copyright © 2011-2022 走看看