Uilabel自动换行 UItableView适应高度

来源:互联网 发布:jdk1.6 for linux 编辑:程序博客网 时间:2024/06/06 04:48
 //设置tableViewcell里uilabel、图片高度    CGSize tbvContentSizeForheight = [cell.resultNoticeTableContent.text sizeWithFont:cell.resultNoticeTableContent.font];    CGSize tbvContentSizeForLines = [cell.resultNoticeTableContent.text sizeWithFont:cell.resultNoticeTableContent.font constrainedToSize:CGSizeMake(280, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];//最大行数    cell.resultNoticeTableContent.numberOfLines =ceil(tbvContentSizeForLines.height/tbvContentSizeForheight.height);//自动换行 if(cell.resultNoticeTableContent.numberOfLines<=1) { cell.resultNoticeTableContent.frame = CGRectMake(20, 80, 290,30); } else  {   int tbvHight = cell.resultNoticeTableContent.frame.size.height*cell.resultNoticeTableContent.numberOfLines;   cell.resultNoticeTableContent.frame = CGRectMake(20, cell.resultNoticeTableContent.frame.origin.y, 290,tbvHight    );   //cell.resultNoticeImageView.image = [UIImage imageNamed:@"BG.png"];   cell.resultNoticeImageView.frame = CGRectMake(10, 50, 300, cell.resultNoticeImageView.bounds.size.height+tbvHig    ht-30); }
原创粉丝点击