zoukankan      html  css  js  c++  java
  • 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
    }
  • 相关阅读:
    Systemd 进程管理教程
    traefik的80和443端口占用进一步分析
    使用KubeOperator安装k8s集群后,节点主机yaml文件路径
    kubernetes1.20 部署 traefik2.3
    数据采集实战(二)-- 京粉商品
    机器人导航(仿真)(三)——路径规划(更新中)
    机器人导航(仿真)(二)——amcl定位
    Tkinter 做简单的窗口视窗 Python GUI
    机器人导航(仿真)(一)——SLAM建图
    (转载)VMware Workstation Ubuntu 20.04 无法连接网络问题
  • 原文地址:https://www.cnblogs.com/qingjoin/p/2727621.html
Copyright © 2011-2022 走看看