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

上一篇:secureCRT The remote system refused the connection.


下一篇:MongoDB - MongoDB CRUD Operations, Query Documents