//
//  ViewController.m
//  testUIPickView
//
//  Created by Friend on 16/3/17.
//  Copyright 漏 2016骞?涓板悏绉戞妧. All rights reserved.
//

#import "ViewController.h"
#import "YPpickViewController.h"

///鑾峰彇褰撳墠灞忓箷鐨勯珮搴?#define kMainScreenHeight ([UIScreen mainScreen].bounds.size.height)
///鑾峰彇褰撳墠灞忓箷鐨勫搴?#define kMianScreenWidth ([UIScreen mainScreen].bounds.size.width)
@interface ViewController ()
{
    UILabel *_timeLable;

}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"UIPickerView";
    self.view.backgroundColor = [UIColor whiteColor];
    _timeLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0,150, 30)];
    _timeLable.text = @"2016-12-12";
    _timeLable.center = CGPointMake(kMianScreenWidth/2, kMainScreenHeight/2-40);
    _timeLable.textAlignment = NSTextAlignmentCenter ;
    _timeLable.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:_timeLable];
    
    
    UIButton *btn = [UIButton buttonWithType:0];
    btn.frame = CGRectMake(0, 0, 120, 40);
    [btn setTitle:@"閫夋嫨鏃ユ湡" forState:0];
    btn.center = CGPointMake(kMianScreenWidth/2, kMainScreenHeight/2+10);
    [btn setTitleColor:[UIColor whiteColor] forState:0];
    btn.backgroundColor = [UIColor blackColor];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}

-(void)btnClick{
//  璋冪敤鐏板父绠€鍗曪紝濡備笅鎵€绀猴紝鐐瑰嚮纭畾鍥炶皟閫夋嫨鐨勬棩鏈?     YPpickViewController *ypVC  = [[YPpickViewController alloc]init];
     ypVC.calendarblock = ^(YPpickViewModel *model){
    
        NSLog(@"%@\n",model.year);
        NSLog(@"%@\n",model.moth);
        NSLog(@"%@\n",model.day);
        _timeLable.text = [NSString stringWithFormat:@"%@-%@-%@",model.year,model.moth,model.day];
    };
    
    [ self.navigationController pushViewController:ypVC animated:YES];
    
    
}

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

@end
// 鐗堟潈灞炰簬鍘熶綔鑰?// http://code4app.com (cn) http://code4app.net (en)
// 鍙戝竷浠g爜浜庢渶涓撲笟鐨勬簮鐮佸垎浜綉绔? Code4App.com