zoukankan      html  css  js  c++  java
  • 腾讯sdk学到了

    1. 获取文本的高度和宽度

    + (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, NSParagraphStyleAttributeName:paragraphStyle.copy};
            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;
    }

    2. autolayout中一直确定不了设备的高度和宽度

    可以使用 layoutSubviews, 但是这个方法会被调用多次, 所以这个方法里只能用于控制frame

    3. sizeToFit

    这个方法是让uiview 根据子视图 来确定size

    常用与UIlabel, 根据文本来确定UILabel的size

    3. - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:

    让uiimageview left和top方向某个范围内不被拉伸, 用于做气泡

  • 相关阅读:
    111
    RH124-3 目录结构_转
    oracle 查看表空间以及日志文件等系统文件
    bash_profile
    linux 7 关闭防火墙 开启sshd服务
    mount 挂载光盘
    oracle 夸服务器、数据库查询
    Oracle中merge into的使用
    restore和recover的区别
    TCP: time wait bucket table overflow解决方法
  • 原文地址:https://www.cnblogs.com/apem/p/4530690.html
Copyright © 2011-2022 走看看