zoukankan      html  css  js  c++  java
  • cell的自适应

    +(CGFloat)getCellHeightWithItem:(FXOwnershipStrutureInfo *)item

    {

        

        if (item.rowH) {//如有rowH就直接返回,避免重新计算

            return item.rowH;

        }

        //计算cell的行高的关键变高控件的高度

     

        NSMutableParagraphStyle *style =  [[NSParagraphStyle defaultParagraphStyle] mutableCopy];

        style.lineSpacing = 6;

     

        CGRect sizeH = [item.memo boundingRectWithSize:CGSizeMake(ScreenWidth - 105, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSParagraphStyleAttributeName : style} context:nil];

     

     

        //返回高度,并缓存rowH

        return item.rowH = 15 + 20 + 10 + 20 + 10  + sizeH.size.height + 15 + 16 ;

        

    }

    // 赋值

    - (void)addtext

           _showContentLb.frame = CGRectMake(15, _grayLable.bottom+15, ScreenWidth-30, 0);

            _showContentLb.numberOfLines = 0;

            NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:self.item.content];

            NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];

            [paragraphStyle1 setLineSpacing:6];// 行间距

            [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [self.item.content length])];

            [ _showContentLb setAttributedText:attributedString1];//赋值

            [ _showContentLb sizeToFit];

     

     

  • 相关阅读:
    web前端要学哪些?
    angularjs factory,service,provider 自定义服务的不同
    PSP软件开发过程
    Eclipse连接sqlserver体验过程
    在线制作GIF图片项目愿景与范围
    C# Hashtable vs Dictionary 学习笔记
    Unity 工作经历+近期面试经历
    配置文件加载的一个坑
    rabbitmq exchange type
    centos7下nginx添加到自定义系统服务中提示Access denied
  • 原文地址:https://www.cnblogs.com/weipeng168/p/5259096.html
Copyright © 2011-2022 走看看