标签:
******************************** IOS6 获取字符串size ********************************
单行字符串: CGSize size_width = [str_new sizeWithFont:[UIFont systemFontOfSize:20]];
多行字符串: CGSize labelSize = [self.textLabel.text sizeWithFont:[UIFont systemFontOfSize:14.0f]
constrainedToSize:CGSizeMake(226.0f, MAXFLOAT)
lineBreakMode:0];
******************************** IOS7 获取字符串size ********************************
单行字符串: CGSize size_width = [str_new sizeWithAttributes: @{NSFontAttributeName:[UIFont systemFontOfSize:20]}];
多行字符串:CGSize labelSize = [self.textLabel.text boundingRectWithSize:CGSizeMake(226, MAXFLOAT) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
备注:
标签:
原文地址:http://www.cnblogs.com/madaha/p/4269963.html