// // LDCollectionNoDataReusableView.m // YouHuiProject // // Created by 小花 on 2018/5/8. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LDCollectionNoDataReusableView.h" @implementation LDCollectionNoDataReusableView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; [self initSubviews]; } return self; } - (void)initSubviews { UIImageView *topImageView = [[UIImageView alloc] init]; topImageView.backgroundColor = [UIColor clearColor]; topImageView.image = [UIImage imageNamed:@"search_no_data"]; [self addSubview:topImageView]; UILabel *topLabel = [[UILabel alloc] init]; topLabel.backgroundColor = [UIColor clearColor]; topLabel.textColor = [UIColor YHColorWithHex:0x333333]; topLabel.font = [UIFont systemFontOfSize:FITSIZE(14)]; topLabel.text = @"没有找到收藏的商品"; [self addSubview:topLabel]; UILabel *middleLabel = [[UILabel alloc] init]; middleLabel.backgroundColor = [UIColor clearColor]; middleLabel.textColor = [UIColor YHColorWithHex:0x888888]; middleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)]; middleLabel.text = @"赶快去收藏吧"; [self addSubview:middleLabel]; UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom]; bottomButton.backgroundColor = [UIColor clearColor]; [bottomButton setTitleColor:[UIColor YHColorWithHex:0x666666] forState:UIControlStateNormal]; bottomButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(15)]; [bottomButton setTitle:@"刷新" forState:UIControlStateNormal]; bottomButton.layer.borderWidth = 1.0f; bottomButton.layer.borderColor = [UIColor YHColorWithHex:0xb3b3b3].CGColor; bottomButton.layer.cornerRadius = 3.0f; [bottomButton addTarget:self action:@selector(refreshButtonAction) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:bottomButton]; [topImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.equalTo(self).offset(FITSIZE(30)); }]; [topLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.equalTo(topImageView.mas_bottom).offset(FITSIZE(22)); }]; [middleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.equalTo(topLabel.mas_bottom).offset(FITSIZE(6)); }]; [bottomButton mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.equalTo(middleLabel.mas_bottom).offset(FITSIZE(20)); make.width.mas_equalTo(FITSIZE(102)); make.height.mas_equalTo(FITSIZE(30)); }]; } - (void)refreshButtonAction { if (self.refreshClick) { self.refreshClick(); } } @end