12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //
- // KBNoDataMsgView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/11/8.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBNoDataMsgView.h"
- @implementation KBNoDataMsgView
- - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
-
- [self initSubviews:title];
- }
- return self;
- }
- - (void)initSubviews:(NSString *)title {
- 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 = title;
- [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(self.height/2-150);
- }];
-
- [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
|