用lable画表格

 CGRect viewRect=self.view.frame;

    //画基本信息

    NSDictionary *basicInformDic=(NSDictionary *)[[[dic objectForKey:@"returnResult"] objectForKey:@"dtBasicInform"] objectAtIndex:0];

    NSDictionary *wageInformDic=(NSDictionary *)[[[dic objectForKey:@"returnResult"] objectForKey:@"dtWageInform"] objectAtIndex:0];

    CGRect basicInformRect=CGRectMake(106,20, viewRect.size.width-106, 200);

    NSArray* basicLabelArray=[NSArray arrayWithObjects:@"姓名",@"出生日期",@"文化程度",@"取得时间",

                         @"",@"籍贯",@"毕业时间",@"政治面貌",

                         @"民族",@"身份证号",@"学位",@"加入时间",

                         nil];

    [self drawGrid:basicInformDic andBakDic:wageInformDic andWidthLabelNumber:3 andHeightLabelNumber:4 andRect:basicInformRect andLabelArray:basicLabelArray];

    //画工资信息

    CGRect wageInformRect=CGRectMake(20, 200+20, viewRect.size.width-20, 300);

    NSArray* wageLabelArray=[NSArray arrayWithObjects:@"单位",@"职务级别",@"岗位工资标准",

                   @"员工编号",@"职称",@"合同编号",

                   @"工作岗位",@"取得资格日期",@"合同类型",

                   @"工作时间",@"公子序列",@"开始日期",

                   @"工龄起算日",@"岗级",@"结束日期",

                   @"首次加入中石油日期",@"档次",

                   nil];

    [self drawGrid:basicInformDic andBakDic:wageInformDic andWidthLabelNumber:2 andHeightLabelNumber:9 andRect:wageInformRect andLabelArray:wageLabelArray];









-(void)drawGrid:(NSDictionary *)informDic andBakDic:(NSDictionary *)informDicBak andWidthLabelNumber:(float )widthLabelNumber andHeightLabelNumber:(float )heightLabelNumber andRect:(CGRect )informRect  andLabelArray:(NSArray *)labelArray

{

    float labelLength=informRect.size.width/widthLabelNumber/2;

    float labelHeitht=informRect.size.height/heightLabelNumber;

    for (NSUInteger i=0; i<heightLabelNumber; i++) 

    {

        for (NSUInteger j=0; j<widthLabelNumber; j++) {

            if (i*widthLabelNumber+j>[labelArray count]-1) {

                continue;

            }

            

            UILabel *lKey = [[UILabel alloc] initWithFrame:CGRectMake(informRect.origin.x+j*labelLength*2

                                                                      informRect.origin.y+i*labelHeitht, 

                                                                      labelLength, labelHeitht)];

            lKey.font = [UIFont systemFontOfSize:14.0f];

            lKey.text = [NSString stringWithFormat:@"%@:",[labelArray objectAtIndex:i*widthLabelNumber+j]];  

            lKey.backgroundColor = [UIColor clearColor];

            lKey.textColor = [UIColor blueColor];

            lKey.textAlignment = UITextAlignmentRight;

            [self.view addSubview:lKey];

            //value

            UILabel *lValue = [[UILabel alloc] initWithFrame:CGRectMake(informRect.origin.x+j*labelLength*2+labelLength,

                                                                        informRect.origin.y+i*labelHeitht, 

                                                                        labelLength, labelHeitht)];

            lValue.font = [UIFont systemFontOfSize:14.0f];

            lValue.text =  [informDic objectForKey: [labelArray objectAtIndex:i*widthLabelNumber+j]];

            lValue.backgroundColor = [UIColor clearColor];

            lValue.textColor =  [UIColor blackColor];

            lValue.textAlignment = UITextAlignmentLeft;

            [self.view addSubview:lValue];

        }

    }

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值