• ios 自定义UITableView中分组的标题sectionview


    //Section的标题栏高度
    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        if (section == 0)
            return 46;
        else
            return 30.0f;
    }
     
     
    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        CGRect headerFrame = CGRectMake(0, 0, 300, 30);
        CGFloat y = 2;
        if (section == 0) {
            headerFrame = CGRectMake(0, 0, 300, 100);
            y = 18;
        }
        UIView *headerView = [[UIView alloc] initWithFrame:headerFrame];
        UILabel *dateLabel=[[UILabel alloc] initWithFrame:CGRectMake(20, y, 240, 24)];//日期标签
        dateLabel.font=[UIFont boldSystemFontOfSize:16.0f];
        dateLabel.textColor = [UIColor darkGrayColor];
        dateLabel.backgroundColor=[UIColor clearColor];
        UILabel *ageLabel=[[UILabel alloc] initWithFrame:CGRectMake(216, y, 88, 24)];//年龄标签
        ageLabel.font=[UIFont systemFontOfSize:14.0];
        ageLabel.textAlignment=UITextAlignmentRight;
        ageLabel.textColor = [UIColor darkGrayColor];
        ageLabel.backgroundColor=[UIColor clearColor];
         
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        dateFormatter.dateFormat = @"MM dd,yyyy";
        dateLabel.text = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:[NSDate date]]];
        ageLabel.text = @"1岁 2天";
         
        [headerView addSubview:dateLabel];
        [headerView addSubview:ageLabel];
        return headerView;
    }
  • 相关阅读:
    angular5 二维码插件
    ag-grid 设置默认选中多行
    断点续传和下载原理分析
    Volley 实现原理图
    Volley全方位解析,带你从源码的角度彻底理解
    23种设计模式
    android service
    Android drawable微技巧
    Android ListView实现不同item的方法和原理分析
    Android 网络框架 volley源码剖析
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/3368263.html
Copyright © 2020-2023  润新知