plist 文件 解析页眉图片

//页眉
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView *headerView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 240)];
// headerView.backgroundColor = [UIColor orangeColor];
// UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
// [btn1 setImage:[UIImage imageNamed:self.tableHeaderDic[@“img1”]] forState:UIControlStateNormal];
// [headerView addSubview:btn1];

headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 240)];
//headerV.backgroundColor = [UIColor cyanColor];

NSString * file = [[NSBundle mainBundle] pathForResource:@"Property List.plist" ofType:nil];
NSDictionary * dic = [NSDictionary dictionaryWithContentsOfFile:file];

for (NSDictionary * dict in dic[@"header"]) {
    
    model * model1 = [model new];
    [model1 setValuesForKeysWithDictionary:dict];
    [self.imgArr addObject:model1];
    
}


for (int i = 0; i<self.imgArr.count; i++) {
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20+i * self.view.frame.size.width/3, 10,80,80)];
    imageView.tag = i+10;
    imageView.image = [UIImage imageNamed:[self.imgArr[i]imgV]];
    if (imageView.tag==11) {
        imageView.frame = CGRectMake(self.view.frame.size.width/4+5, 10,80,80);
    }
    if (imageView.tag==12) {
        imageView.frame = CGRectMake((self.view.frame.size.width/4+8)*2-25, 10,self.view.frame.size.width/4*2-30,80);
    }
    if (imageView.tag==13) {
        imageView.frame =CGRectMake(20,100,80,80);
    }else if (imageView.tag==14){
        imageView.frame =CGRectMake(self.view.frame.size.width/4+5,100,80,80);
    }else if (imageView.tag==15){
        imageView.frame =CGRectMake(2*self.view.frame.size.width/4-10,100,80,80);
    }else if (imageView.tag==16){
        imageView.frame =CGRectMake(3*self.view.frame.size.width/4-18,100,80,80);
    }
    [tab addSubview:imageView];
}

return headerView;

}

猜你喜欢

转载自blog.csdn.net/qq_43361450/article/details/84141855