//
//  HistoryViewController.m
//  vanke
//
//  Created by Z on 16/4/18.
//  Copyright © 2016年 gomore. All rights reserved.
//

#import "HistoryViewController.h"
#import "HistoryTopView.h"

#define kListWidth 100 //一个表格的宽度
#define kListHeight 44
#define kBottomHeight 60 //表格最底部的那行的宽度
@interface HistoryViewController ()
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, strong) UIScrollView *scrollView;
@end

@implementation HistoryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.title = @"历史";
    self.titles = @[@"标题1",@"标题2",@"标题2",@"标题2",@"标题2"];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setUpTopView];
    [self setUPScrollView];
    // Do any additional setup after loading the view.
}


- (void)setUPScrollView {
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 150, SCREEN_WIDTH, SCREEN_HEIGHT - 150 - 64)];
    self.scrollView.contentSize = CGSizeMake(kListWidth * self.titles.count, kListHeight * 19 + kBottomHeight);
    for (int i = 0; i < self.titles.count; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(kListWidth * i, 0, kListWidth, 44)];
        label.text = self.titles[i];
        label.font = [UIFont systemFontOfSize:19];
        label.textAlignment = NSTextAlignmentCenter;
        [self.scrollView addSubview:label];
        
        for (int j = 0; j < 19; j++) {
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(kListWidth * i, kListHeight +  kListHeight * j, kListWidth, kListHeight)];
            label.textAlignment = NSTextAlignmentCenter;
            label.text = [NSString stringWithFormat:@"假数据假%d", j];
            [self.scrollView addSubview:label];
        }
        
        UILabel *labelBottom = [[UILabel alloc] initWithFrame:CGRectMake(kListWidth * i, kListHeight +  kListHeight * 18, kListWidth, kBottomHeight)];
        labelBottom.text = self.titles[i];
        labelBottom.backgroundColor = [UIColor grayColor];
        labelBottom.font = [UIFont systemFontOfSize:20];
        labelBottom.textAlignment = NSTextAlignmentCenter;
        [self.scrollView addSubview:labelBottom];
        
    }
    [self.view addSubview:self.scrollView];
}


- (void)setUpTopView {
    HistoryTopView *topView = [self viewWithNibName:@"HistoryTopView"];
    topView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 150);
    [self.view addSubview:topView];
}


- (id)viewWithNibName:(NSString *)viewName {
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:viewName owner:nil options:nil];
    return [nibView objectAtIndex:0];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
