+ (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方向某個範圍內不被展開, 用於做氣泡