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

     

  • 相关阅读:
    洛谷 P1886 滑动窗口(单调队列)
    POJ 2559 Largest Rectangle in a Histogram(单调栈)
    eclipse开发velocity实例(初学)
    Spring MVC 教程,快速入门,深入分析
    传智博客(JavaWeb方面的所有知识)听课记录(经典)
    JSP/SERVLET入门教程--Servlet 使用入门
    javaweb入门实例---servlet例子
    Eclipse快捷键大全(转载)
    简单java web应用程序搭建与部署
    Servlet 工作原理解析
  • 原文地址:https://www.cnblogs.com/shenlaiyaoshi/p/9465076.html
Copyright © 2011-2022 走看看