zoukankan      html  css  js  c++  java
  • ios计算内容的高度 (含7.0前及以后的版本的用法)

    + (CGFloat)heightForContent:(MyMsgTextModel *)content withWidth:(CGFloat)width

    {

        CGSize contentSize;

        if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {

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

            paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;

            NSDictionary *attributes = @{NSFontAttributeName:CELL_CONTENT_FONT_SIZE};

            

            contentSize = [content.textMsg boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size;

        }

        else{

            contentSize = [content.textMsg sizeWithFont:CELL_CONTENT_FONT_SIZE constrainedToSize:CGSizeMake(width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];

        }

        return contentSize.height;

    }

  • 相关阅读:
    C语言 · 阶乘计算 · 基础练习
    C语言 · 查找整数 · 基础练习
    UML课程复习重点
    运维参考
    mysql语法总结
    Python杂篇
    Python练习题
    Python参考
    k8s中ipvs和iptables选择
    安装cni网络插件-非必须
  • 原文地址:https://www.cnblogs.com/NSong/p/5424932.html
Copyright © 2011-2022 走看看