Toolview.m 3.67 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1 2 3 4 5 6 7 8 9 10
//
//  Toolview.m
//  Lighting
//
//  Created by 曹云霄 on 16/4/27.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "Toolview.h"
#import "CustomButton.h"
zhu's avatar
zhu committed
11

曹云霄's avatar
曹云霄 committed
12
#define ButtonWIDTH 80 //按钮宽度
zhu's avatar
zhu committed
13 14 15 16
#define Buttoninterval 20//按钮间隔
#define ButtonRIGHT 54//按钮高度


曹云霄's avatar
曹云霄 committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
@implementation Toolview

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
      
曹云霄's avatar
曹云霄 committed
32
        self.backgroundColor = kTCColor(255, 255, 255);
曹云霄's avatar
曹云霄 committed
33 34 35 36 37 38 39 40
        [self uiConfigAction];
    }
    return self;
}

#pragma mark -布局
- (void)uiConfigAction
{
曹云霄's avatar
曹云霄 committed
41 42 43 44 45 46 47 48 49 50
    //阴影
    self.layer.shadowColor = [UIColor blackColor].CGColor;
    self.layer.shadowRadius = 6;
    self.layer.shadowOpacity = 0.8;
    
    //图标
    UIImageView *iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(50, 10, 100, 45)];
    iconImage.image = TCImage(@"weibo");
    [self addSubview:iconImage];
    
曹云霄's avatar
曹云霄 committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64
    //输入框背景
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(200, (NavigationHeight-35)/2, 220, 35)];
    backView.backgroundColor = kTCColor(242, 242, 242);
    backView.layer.masksToBounds = YES;;
    backView.layer.cornerRadius = kCornerRadius;
    backView.layer.borderWidth = 1;
    backView.layer.borderColor = kTCColor(209, 209, 209).CGColor;
    [self addSubview:backView];

    //搜索图标
    
    
    
    
曹云霄's avatar
曹云霄 committed
65
    //输入框
曹云霄's avatar
曹云霄 committed
66
    UITextField *inputField = [[UITextField alloc]initWithFrame:CGRectMake(50, 0, 170, 35)];
曹云霄's avatar
曹云霄 committed
67 68
    inputField.borderStyle = UITextBorderStyleNone;
    inputField.placeholder = @"请输入关键字";
曹云霄's avatar
曹云霄 committed
69 70 71
    inputField.font = [UIFont systemFontOfSize:12];
    [backView addSubview:inputField];
    
曹云霄's avatar
曹云霄 committed
72
    
曹云霄's avatar
曹云霄 committed
73

曹云霄's avatar
曹云霄 committed
74
    //按钮
zhu's avatar
zhu committed
75 76
    NSArray *titleArray = [NSArray arrayWithObjects:@"右视图",@"某某用户",@"我的客户",@"购物车", nil];
    for (int i=1; i<5; i++) {
曹云霄's avatar
曹云霄 committed
77 78 79 80
        
        CustomButton *button = [CustomButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(ScreenWidth-(i*ButtonWIDTH + Buttoninterval*(i-1)), 10, ButtonWIDTH, ButtonRIGHT);
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
曹云霄's avatar
曹云霄 committed
81 82 83
        [button setTitle:[titleArray objectAtIndex_opple:i-1] forState:UIControlStateNormal];
        button.tag = 100+i-1;
        [button addTarget:self action:@selector(ButtonClick:) forControlEvents:UIControlEventTouchUpInside];
曹云霄's avatar
曹云霄 committed
84 85 86
        if (i == 4) {
          button.instructionsNumber = i;
        }
zhu's avatar
zhu committed
87 88 89 90
        if (i==1) {
            [button setImage:TCImage(@"business") forState:UIControlStateNormal];
        }else
        {
曹云霄's avatar
曹云霄 committed
91
            [button setImage:TCImage(@"data") forState:UIControlStateNormal];
zhu's avatar
zhu committed
92
        }
曹云霄's avatar
曹云霄 committed
93 94
        [self addSubview:button];
    }
曹云霄's avatar
曹云霄 committed
95 96 97 98 99 100 101
    
//    //创建下划线
//    CustomButton *button = (CustomButton *)[self viewWithTag:102];
//    self.underlineView = [[UIView alloc]initWithFrame:CGRectMake(button.frame.origin.x+(ButtonWIDTH-50)/2, ButtonRIGHT+9, 50, 1)];
//    _underlineView.backgroundColor = [UIColor redColor];
//    [self addSubview:self.underlineView];
    
曹云霄's avatar
曹云霄 committed
102 103 104
}


曹云霄's avatar
曹云霄 committed
105 106 107
#pragma mark -按钮事件响应
- (void)ButtonClick:(UIButton *)button
{
曹云霄's avatar
曹云霄 committed
108 109 110 111 112 113 114
//    //下划线动画
//    [UIView animateWithDuration:0.2 animations:^{
//        
//        CGRect frame = self.underlineView.frame;
//        frame.origin.x = button.frame.origin.x+(ButtonWIDTH-50)/2;
//        self.underlineView.frame = frame;
//    }];
曹云霄's avatar
曹云霄 committed
115 116 117 118
    
    //点击代理
    if ([self.delegate respondsToSelector:@selector(ButtonClickAction:)]) {
        
曹云霄's avatar
曹云霄 committed
119
        [self.delegate ButtonClickAction:button.tag];
曹云霄's avatar
曹云霄 committed
120 121
    }
}
曹云霄's avatar
曹云霄 committed
122 123 124 125 126




@end