iOS7中Cell高度 Label高度自适应

时间:2014-06-13 07:19:54   收藏:0   阅读:413
1
2
3
4
5
6
7
8
9
10
11
12
?- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
 
    NSString *str = [_dataArray objectAtIndex:indexPath.row];
    UIFont *tfont = [UIFont systemFontOfSize:14.0];
    NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil];
    //   ios 7
    CGSize sizeText = [str boundingRectWithSize:CGSizeMake(320, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
    //   ios 6
    CGSize sizeText1 = [str sizeWithFont:[UIFont systemFontOfSize:16.0f] constrainedToSize:CGSizeMake(320, 1000) lineBreakMode:NSLineBreakByCharWrapping];
    return sizeText1.height+50;    
 
}?

iOS7中Cell高度 Label高度自适应,布布扣,bubuko.com

原文:http://www.cnblogs.com/jz319/p/3781325.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!