//
//  ViewController.m
//  YQYPiecewiseDemo
//
//  Created by dongguoju on 16/3/10.
//  Copyright (c) 2016骞?yangqiyao. All rights reserved.
//

#import "ViewController.h"
#import "YQYPiecewiseView.h"
@interface ViewController ()<YQYPiecewiseViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray *arrar = [NSArray arrayWithObjects:@"鏍囬涓€",@"鏍囬浜?,@"鏍囬涓?, nil];
    YQYPiecewiseView *piecew = [[YQYPiecewiseView alloc]initWithFrame:CGRectMake(10, 80, 300, 60)];
    piecew.backgroundColor = [UIColor yellowColor];
    piecew.type = PiecewiseInterfaceTypeBackgroundChange;
    piecew.tag = 21;
    piecew.textNormalColor = [UIColor greenColor];
    piecew.delegate = self;
    piecew.backgroundNormalColor = [UIColor grayColor];
    piecew.backgroundSeletedColor = [UIColor redColor];
    [piecew loadTitleArray:arrar];
    [self.view addSubview:piecew];
    
    YQYPiecewiseView *piecew2 = [[YQYPiecewiseView alloc]initWithFrame:CGRectMake(10, 240, 300, 50)];
    piecew2.backgroundColor = [UIColor yellowColor];
    piecew2.type = PiecewiseInterfaceTypeMobileLin;
    piecew2.tag = 22;
    piecew2.delegate = self;
    piecew2.textFont = [UIFont systemFontOfSize:14];
    piecew2.textNormalColor = [UIColor grayColor];
    piecew2.textSeletedColor = [UIColor  redColor];
    piecew2.linColor = [UIColor redColor];
    [piecew2 loadTitleArray:arrar];
    [self.view addSubview:piecew2];
    
    NSArray *normalImage = [NSArray arrayWithObjects:@"button_seleted",@"button_seleted",nil];
    NSArray *seletedImage = [NSArray arrayWithObjects:@"button_normal",@"button_normal", nil];
    YQYPiecewiseView *piecew3 = [[YQYPiecewiseView alloc]initWithFrame:CGRectMake(10, 340, 300, 60)];
    piecew3.type = PiecewiseInterfaceTypeCustomImage;
    piecew3.tag = 23;
    piecew3.delegate = self;
    [piecew3 loadNormalImage:normalImage seletedImage:seletedImage];
    [self.view addSubview:piecew3];
    
}

-(void)piecewiseView:(YQYPiecewiseView *)piecewiseView index:(NSInteger)index
{
    
    if (piecewiseView.tag == 21) {
        switch (index) {
            case 0:
            {
                NSLog(@"涓嬪垝绾跨被鍨嬶紝鎸夐挳1");
            }
                break;
            case 1:
            {
                NSLog(@"涓嬪垝绾跨被鍨嬶紝鎸夐挳2");
            }
                break;
            case 2:
            {
                NSLog(@"涓嬪垝绾跨被鍨嬶紝鎸夐挳3");
            }
                break;
                
            default:
                break;
        }
    }else if (piecewiseView.tag == 22){
        switch (index) {
            case 0:
            {
                NSLog(@"鑳屾櫙鍙樻崲绫诲瀷锛屾寜閽?");
            }
                break;
            case 1:
            {
                NSLog(@"鑳屾櫙鍙樻崲绫诲瀷锛屾寜閽?");
            }
                break;
            case 2:
            {
                NSLog(@"鑳屾櫙鍙樻崲绫诲瀷锛屾寜閽?");
            }
                break;
                
            default:
                break;
        }

    
    }else{
    
        switch (index) {
            case 0:
            {
                NSLog(@"鑷畾涔夌被鍨嬶紝鎸夐挳1");
            }
                break;
            case 1:
            {
                NSLog(@"鑷畾涔夌被鍨嬶紝鎸夐挳2");
            }
                break;
                
            default:
                break;
        }

    }
    
}

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