// // IfishHistoryView.m // Ifish // // Created by 罗艺 on 2018/8/27. // Copyright © 2018年 lianlian. All rights reserved. // #import "IfishHistoryView.h" #import "IfishChatView.h" #import "IfishHistroyVo.h" #import "PNChart.h" #import "SVProgressHUD.h" @interface IfishHistoryView() Strong UIButton *bgButton; Strong UIView *bgView; Strong IfishChatView *chartView; Strong IfishChatView *chartHolder; Strong UILabel *titleLabel; Strong UIButton *predayButton; Strong UIButton *nextdayButton; Strong UIImageView *bgImage; @property(nonatomic,strong)NSMutableArray*line1; @end @implementation IfishHistoryView - (instancetype)init { self = [super init]; if (self) { [self addSubview:self.bgButton]; [self addSubview:self.bgView]; [self.bgView addSubview:self.titleLabel]; [self.bgView addSubview:self.bgImage]; [self.bgView addSubview:self.chartHolder]; [self.bgView addSubview:self.predayButton]; [self.bgView addSubview:self.nextdayButton]; [self loadLayout]; } return self; } - (UIButton *)bgButton{ if (!_bgButton) { _bgButton = InitObject(UIButton); [_bgButton setBackgroundColor:RGBA(0, 0, 0, 0.3)]; [_bgButton addTarget:self action:@selector(bgButtonClick:) forControlEvents:UIControlEventTouchUpInside]; } return _bgButton; } - (UIView *)bgView{ if (!_bgView) { _bgView = InitObject(UIView); _bgView.backgroundColor = XWhite; _bgView.layer.masksToBounds = YES; _bgView.layer.cornerRadius = 15; } return _bgView; } - (UIImageView *)bgImage{ if (!_bgImage) { _bgImage = InitObject(UIImageView); [_bgImage setImage:IMAGEBYENAME(@"history_bg")]; } return _bgImage; } - (IfishChatView *)chartHolder{ if (!_chartHolder) { _chartHolder = InitObject(IfishChatView); _chartHolder.backgroundColor = [UIColor clearColor]; } return _chartHolder; } - (UILabel *)titleLabel{ if (!_titleLabel) { _titleLabel = InitObject(UILabel); _titleLabel.textAlignment = NSTextAlignmentCenter; _titleLabel.textColor = RGB(51, 51, 51); _titleLabel.font = [UIFont systemFontOfSize:13]; } return _titleLabel; } - (UIButton *)predayButton{ if (!_predayButton) { _predayButton = InitObject(UIButton); // [_predayButton setTitle:@"前一天" forState:UIControlStateNormal]; [_predayButton addTarget:self action:@selector(dayChangeClick:) forControlEvents:UIControlEventTouchUpInside]; [_predayButton.titleLabel setFont:[UIFont systemFontOfSize:13]]; // [_predayButton setTitleColor:RGB(51, 51, 51) forState:UIControlStateNormal]; _predayButton.tag = 10; } return _predayButton; } - (UIButton *)nextdayButton{ if (!_nextdayButton) { _nextdayButton = InitObject(UIButton); // [_nextdayButton setTitle:@"后一天" forState:UIControlStateNormal]; [_nextdayButton addTarget:self action:@selector(dayChangeClick:) forControlEvents:UIControlEventTouchUpInside]; [_nextdayButton.titleLabel setFont:[UIFont systemFontOfSize:13]]; // [_nextdayButton setTitleColor:RGB(51, 51, 51) forState:UIControlStateNormal]; _nextdayButton.tag = 11; } return _nextdayButton; } -(void)loadLayout{ [self.bgButton mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self); }]; [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(kSizeFrom750(720)); make.center.mas_equalTo(self); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.bgView); make.top.mas_equalTo(4); make.height.mas_equalTo(20); }]; [self.bgImage mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(8); make.centerX.width.mas_equalTo(self.bgView); make.height.mas_equalTo(kSizeFrom750(335)); make.bottom.mas_equalTo(self.bgView.mas_bottom).offset(-10); }]; [self.chartHolder mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.width.mas_equalTo(self.bgImage); make.height.mas_equalTo(kSizeFrom750(260)); }]; [self.predayButton mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(kSizeFrom750(20)); make.height.mas_equalTo(kSizeFrom750(60)); make.width.mas_equalTo(kSizeFrom750(120)); make.bottom.mas_equalTo(self.bgView.mas_bottom); }]; [self.nextdayButton mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.centerY.mas_equalTo(self.predayButton); make.right.mas_equalTo(-kSizeFrom750(40)); }]; [self.bgImage layoutIfNeeded]; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ -(IfishChatView *)chartView{ if (_chartView==nil) { _chartView=[[IfishChatView alloc]init]; _chartView.frame=self.chartHolder.bounds; _chartView.backgroundColor=[UIColor clearColor]; [self.chartHolder addSubview:_chartView]; } return _chartView; } -(void)setDatas:(NSArray *)datas{ _datas=datas; if (datas.count<1) { // [SVProgressHUD showInfoWithStatus:@"暂无数据"]; return; } if (self.chartView) { [self.chartView removeFromSuperview]; _chartView=nil; } self.chartView.datas=datas; [self.chartView reloadHeater]; self.titleLabel.text=self.curdateStr; // [self initLineChart]; } #pragma mark --buttonClick -(void)bgButtonClick:(UIButton *)sender{ self.hidden=YES; } -(void)dayChangeClick:(UIButton *)sender{ [self.myDeleget clickBottomBarWithIdx:sender.tag]; } @end