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方向某个范围内不被拉伸, 用于做气泡

  • 相关阅读:
    Leetcode Substring with Concatenation of All Words
    Leetcode Divide Two Integers
    Leetcode Edit Distance
    Leetcode Longest Palindromic Substring
    Leetcode Longest Substring Without Repeating Characters
    Leetcode 4Sum
    Leetcode 3Sum Closest
    Leetcode 3Sum
    Leetcode Candy
    Leetcode jump Game II
  • 原文地址:https://www.cnblogs.com/apem/p/4530690.html
Copyright © 2011-2022 走看看