UIlabel 最小字体设置。

 //字体大小设置
cell.resultTableContent.font = [UIFont systemFontOfSize:13];
//最小字体设置。如果当内容比较多时。没有设置最小字体的话。那么这时字体就会变小。如果设置了最小字体和上面的大小 是一样的。那么字体就比较统一了。
        cell.resultTableContent.minimumFontSize = 13.0;





//设 置UItableViewCell里面  uilabel字体大小 自动适应。可以在这个方法里设置
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"222");
    SchoolInHandAppDelegate *app = [[UIApplication sharedApplication]delegate];
    ReadNoticeInterface *readNotice = [[ReadNoticeInterface alloc]init];
    
    //计算出标题与内容所所占的行数。用于返回tableViewcell高度
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel.frame = CGRectMake(20, 55, 280, 30);
    titleLabel.font = [UIFont systemFontOfSize:17];
    int titleCellCount;
    int titleCellCountHight;
    
    UILabel *label = [[UILabel alloc]init];
    label.frame = CGRectMake(20, 80, 280, 30);
    label.font = [UIFont systemFontOfSize:14];
    int tableViewCellCount;
    int tableViewCellCountHight;
    if(indexPath.row< app.moudle.specificNoticeCount)
    {
        [readNotice switchTableCellContent:app.moudle.READFORNOTICETYPE :indexPath.row];
        //计算出通知内容占几行
        label.text = app.moudle.specificnoticeContent;
        CGSize labelSizeForheight = [label.text sizeWithFont:label.font];
        CGSize labelSizeForLines = [label.text sizeWithFont:label.font constrainedToSize:CGSizeMake(280, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
        label.numberOfLines =ceil(labelSizeForLines.height/labelSizeForheight.height);
        tableViewCellCount = label.numberOfLines;
        tableViewCellCountHight=labelSizeForLines.height;
        
        //计算出标题通知占几行
        titleLabel.text = app.moudle.specificnoticeTitle;
        //titleLabel.text = @"sadfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasfasdfasdfsdfdfasdfasdfasdf";
        CGSize labelSizeForheightT = [titleLabel.text sizeWithFont:titleLabel.font];
        CGSize labelSizeForLinesT = [titleLabel.text sizeWithFont:titleLabel.font constrainedToSize:CGSizeMake(280, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
        titleLabel.numberOfLines =ceil(labelSizeForLinesT.height/labelSizeForheightT.height);
        titleCellCount = titleLabel.numberOfLines;
        titleCellCountHight=labelSizeForLinesT.height;
        //NSLog(@"Tcount:%d Thight:%d",titleCellCount,titleCellCountHight);
        
        
        if(app.moudle.JUDGETEACHERSTUDENT == COMMUNICATION_ATHERS)
        {
            if(tableViewCellCount<=1)
            {
                if(titleCellCount<=1)
                {
                    return 110; 
                }
                else 
                {
                    return 110+titleCellCountHight-21;
                }
               
            }
            else
            {
                if(titleCellCount<=1)
                {
                   return 110+tableViewCellCountHight-16; 
                }
                else 
                {
                   return 110+tableViewCellCountHight-16+titleCellCountHight-21; 
                }
            }
        }
        else
        {
            return 53;
        }

    
    }
    else if(indexPath.row == app.moudle.specificNoticeCount)
    {
        return 30;
    }
    else 
    {
        return 20;
    }
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   //do something
}

转载于:https://www.cnblogs.com/qingjoin/archive/2012/10/17/2727621.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值