zoukankan      html  css  js  c++  java
  • TableViewCell 自适应高度.

    //根据内容长度,调整Lable高度.

    +(CGFloat)heightWithContent:(NSString *)string{

        NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:16]};

    return [string boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width-20, 1000)options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size.height;

    }

    //根据Lable高度调整Cell的高度.

    +(CGFloat)heightForRowWithModel:(Model *)model{

        return [self heightWithContent:model.content]+50;

    }

    可视化中:

    给lable加约束,只约束距上,左,右,的距离.

    cell,在代码中

         //给出cell高度预算值 

     self.tableView.estimatedRowHeight = 100;

         //cell高度自己计算      

    self.tableView.rowHeight= UITableViewAutomaticDimension;

  • 相关阅读:
    I-Cache和D-cache
    socat使用
    反射
    属性方法
    getitem
    文件打开编辑和函数参数
    python3编码问题个人理解
    正文内容 python3编码问题
    进度条制作
    集合关系
  • 原文地址:https://www.cnblogs.com/wukun168/p/6010808.html
Copyright © 2011-2022 走看看