美文网首页
cell中label高度的自动计算(转)

cell中label高度的自动计算(转)

作者: 夜空已沉寂 | 来源:发表于2016-10-24 10:54 被阅读51次

    -(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{if(tableView==kindTableView){NSIntegersection=indexPath.section;customCell*cell=(customCell*)[tableViewdequeueReusableCellWithIdentifier:customCellView];if(cell==nil){[[NSBundlemainBundle]loadNibNamed:@"customCell"owner:selfoptions:nil];cell=_customCell;}FileListItem*item=[cuArrayobjectAtIndex:indexPath.row];cell.textLabel.text=item.name;//主要是这里,上面的按平常各自的习惯写cell.textLabel.lineBreakMode=NSLineBreakByWordWrapping;cell.textLabel.numberOfLines=0;cell.textLabel.font=[UIFontfontWithName:@"Helvetica"size:17.0];UIFont*cellFont=[UIFontfontWithName:@"Helvetica"size:17.0];CGSizeconstraintSize=CGSizeMake(280.0f,MAXFLOAT);CGSizelabelSize=[cell.textLabel.textsizeWithFont:cellFontconstrainedToSize:constraintSizelineBreakMode:NSLineBreakByWordWrapping];CGRectframe=cell.textLabel.frame;cell.textLabel.frame=CGRectMake(frame.origin.x,((labelSize.height+20)-frame.size.height)/2,frame.size.width,frame.size.height);}returncell;}//设置cell每行间隔的高度-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:(NSIndexPath*)indexPath{NSString*cellText=item.name;UIFont*cellFont=[UIFontfontWithName:@"Helvetica"size:17.0];CGSizeconstraintSize=CGSizeMake(280.0f,MAXFLOAT);CGSizelabelSize=[cellTextsizeWithFont:cellFontconstrainedToSize:constraintSizelineBreakMode:NSLineBreakByWordWrapping];returnlabelSize.height+20;}

    一,导航栏为黑色(或深色),想要设置状态栏字体颜色为白色,注意我说的是状态栏字体颜色.

    1,在 info.plist 文件中设置字段View controller-based status bar appearance 为Bool 类型 NO.

    2,在 info.plist 文件中设置字段Status bar style为 字符串类型UIStatusBarStyleLightContent.

    3,再次运行项目就可看到状态栏字体颜色成为白色.

    相关文章

      网友评论

          本文标题:cell中label高度的自动计算(转)

          本文链接:https://www.haomeiwen.com/subject/rbqluttx.html