Commit 7ad5a431 authored by licong's avatar licong

完成

parent 7168a5d8
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
self.clipsToBounds = YES;
} }
return self; return self;
} }
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
_tipIcon = [UIImageView new]; _tipIcon = [UIImageView new];
_tipLabel = [UILabel new]; _tipLabel = [UILabel new];
_tipButton = [OCRedGradientButton buttonWithType:UIButtonTypeCustom]; _tipButton = [OCRedGradientButton buttonWithType:UIButtonTypeCustom];
_tipButton.frame = CGRectMake(0, 0, 10, 10); //给一个默认的rect,让系统调用DrawRect方法
[self addSubview:_tipIcon]; [self addSubview:_tipIcon];
[self addSubview:_tipLabel]; [self addSubview:_tipLabel];
[self addSubview:_tipButton]; [self addSubview:_tipButton];
...@@ -106,16 +107,8 @@ ...@@ -106,16 +107,8 @@
- (void)layoutSubviews { - (void)setType:(OCEmptyViewType)type{
[super layoutSubviews]; _type = type;
[_tipIcon mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.centerY.equalTo(self).offset(-75);
}];
[_tipLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tipIcon.mas_bottom).offset(-35);
make.centerX.mas_equalTo(self);
}];
switch (self.type) { switch (self.type) {
case OCEmptyViewTypeEmpty:{ case OCEmptyViewTypeEmpty:{
_tipButton.hidden = YES; _tipButton.hidden = YES;
...@@ -127,16 +120,16 @@ ...@@ -127,16 +120,16 @@
_tipButton.hidden = NO; _tipButton.hidden = NO;
_tipIcon.image = [UIImage imageNamed:@"network_failed"]; _tipIcon.image = [UIImage imageNamed:@"network_failed"];
_tipLabel.text = @"哎呀!出错了!"; _tipLabel.text = @"哎呀!出错了!";
[_tipButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tipIcon.mas_bottom).offset(15);
make.centerX.equalTo(self);
make.width.mas_equalTo(150);
make.height.mas_equalTo(33);
}];
} }
default: default:
break; break;
} }
}
- (void)layoutSubviews {
[super layoutSubviews];
if (_tipImage.length > 0) { if (_tipImage.length > 0) {
_tipIcon.image = [UIImage imageNamed:_tipImage]; _tipIcon.image = [UIImage imageNamed:_tipImage];
} }
...@@ -144,6 +137,27 @@ ...@@ -144,6 +137,27 @@
_tipLabel.text = _tipText; _tipLabel.text = _tipText;
} }
} }
- (void)updateConstraints{
[super updateConstraints];
[_tipIcon mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.centerY.equalTo(self).offset(-75);
}];
[_tipLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tipIcon.mas_bottom).offset(-35);
make.centerX.mas_equalTo(self);
}];
[_tipButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tipIcon.mas_bottom).offset(15);
make.centerX.equalTo(self);
make.width.mas_equalTo(150);
make.height.mas_equalTo(33);
}];
}
- (void)reloadBtnTap { - (void)reloadBtnTap {
if ([self.delegate respondsToSelector:@selector(emptyViewDidClickReload)]) { if ([self.delegate respondsToSelector:@selector(emptyViewDidClickReload)]) {
[self.delegate emptyViewDidClickReload]; [self.delegate emptyViewDidClickReload];
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#import "OCEmptyView.h" #import "OCEmptyView.h"
#import "WMFetchDataViewModel.h" #import "WMFetchDataViewModel.h"
@interface WMBaseListViewController : WMBaseViewController<UITableViewDelegate,UITableViewDataSource> @interface WMBaseListViewController : WMBaseViewController<UITableViewDelegate,UITableViewDataSource, OCEmptyViewDelegate>
{ {
UITableView *_table; UITableView *_table;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#import <GMRefresh/GMRefreshHeader.h> #import <GMRefresh/GMRefreshHeader.h>
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
@interface WMBaseListViewController () <OCEmptyViewDelegate> @interface WMBaseListViewController ()
@end @end
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
_emptyView.type = type; _emptyView.type = type;
_emptyView.hidden = NO; _emptyView.hidden = NO;
_emptyView.tipText = [self getEmptyText]; _emptyView.tipText = [self getEmptyText];
[_emptyView setNeedsLayout]; [_emptyView setNeedsUpdateConstraints];
} }
- (void)hideEmptyView { - (void)hideEmptyView {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment