123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // TimeBar.m
- // jiaPeiC
- //
- // Created by apple on 16/6/14.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "TimeBar.h"
- #import "DateView.h"
- @implementation TimeBar
- -(id)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
-
- //初始值
- _beginTime = @"开始时间";
- _endTime = @"结束时间";
-
- CGFloat x = 20;
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(x, 5, 80, 30);
- btn.backgroundColor = lineColor;
- [btn setTitle:@"开始时间" textColor:contentTextColor font:Font16 fotState:UIControlStateNormal];
- [btn borderColor:lineColor width:1 cornorRadios:5];
- [btn target:self Tag:1];
- [self addSubview:btn];
- beginBtn = btn;
- [btn addViewWithRect:CGRectMake(x + 82, 20, 16, 1)];
-
- x += 100;
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(x, 5, 80, 30);
- btn.backgroundColor = lineColor;
- [btn setTitle:@"结束时间" textColor:contentTextColor font:Font16 fotState:UIControlStateNormal];
- [btn borderColor:lineColor width:1 cornorRadios:5];
- [btn target:self Tag:2];
- [self addSubview:btn];
- endBtn = btn;
-
- x = frame.size.width - 46;
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(x, 7, 26, 26);
- [btn setImage:[UIImage imageNamed:@"garbage.png"] forState:UIControlStateNormal];
- [btn target:self Tag:3];
- [self addSubview:btn];
- }
- return self;
- }
- -(void)showWithRemove:(MyBlockType)remove
- {
- removeBlock = remove;
- }
- -(void)finishEndTime:(MyBlockType)endTimeB
- {
- endTimeBlock = endTimeB;
- }
- -(void)btnClick:(UIButton *)sender
- {
- if (sender.tag == 3) {
- if (removeBlock) {
- removeBlock(_timeTag);
- }
- return;
- }
-
- DateView* dv = [[DateView alloc] init];
- [dv setStyle:1];
- [dv showWithComplete:^(NSString *time) {
-
- if (sender.tag == 1) {
- _beginTime = time;
- [beginBtn setTitle:time forState:UIControlStateNormal];
- }
- if (sender.tag == 2) {
- _endTime = time;
- [endBtn setTitle:time forState:UIControlStateNormal];
-
- if (endTimeBlock) {
- endTimeBlock(_timeTag);
- }
- }
- }];
- }
- -(void)setBeginAndEndTimeWithBeginTime:(NSString *)beginString EndTime:(NSString *)endString
- {
- _beginTime = beginString;
- _endTime = endString;
-
- [beginBtn setTitle:beginString forState:UIControlStateNormal];
- [endBtn setTitle:endString forState:UIControlStateNormal];
- }
- @end
|