Commit 7ad5a431 authored by licong's avatar licong

完成

parent 7168a5d8
......@@ -16,7 +16,7 @@
{
self = [super init];
if (self) {
self.clipsToBounds = YES;
}
return self;
}
......@@ -86,6 +86,7 @@
_tipIcon = [UIImageView new];
_tipLabel = [UILabel new];
_tipButton = [OCRedGradientButton buttonWithType:UIButtonTypeCustom];
_tipButton.frame = CGRectMake(0, 0, 10, 10); //给一个默认的rect,让系统调用DrawRect方法
[self addSubview:_tipIcon];
[self addSubview:_tipLabel];
[self addSubview:_tipButton];
......@@ -106,16 +107,8 @@
- (void)layoutSubviews {
[super layoutSubviews];
[_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);
}];
- (void)setType:(OCEmptyViewType)type{
_type = type;
switch (self.type) {
case OCEmptyViewTypeEmpty:{
_tipButton.hidden = YES;
......@@ -127,16 +120,16 @@
_tipButton.hidden = NO;
_tipIcon.image = [UIImage imageNamed:@"network_failed"];
_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:
break;
}
}
- (void)layoutSubviews {
[super layoutSubviews];
if (_tipImage.length > 0) {
_tipIcon.image = [UIImage imageNamed:_tipImage];
}
......@@ -144,6 +137,27 @@
_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 {
if ([self.delegate respondsToSelector:@selector(emptyViewDidClickReload)]) {
[self.delegate emptyViewDidClickReload];
......
......@@ -11,7 +11,7 @@
#import "OCEmptyView.h"
#import "WMFetchDataViewModel.h"
@interface WMBaseListViewController : WMBaseViewController<UITableViewDelegate,UITableViewDataSource>
@interface WMBaseListViewController : WMBaseViewController<UITableViewDelegate,UITableViewDataSource, OCEmptyViewDelegate>
{
UITableView *_table;
......
......@@ -11,7 +11,7 @@
#import <GMRefresh/GMRefreshHeader.h>
#import <Masonry/Masonry.h>
@interface WMBaseListViewController () <OCEmptyViewDelegate>
@interface WMBaseListViewController ()
@end
......@@ -211,7 +211,7 @@
_emptyView.type = type;
_emptyView.hidden = NO;
_emptyView.tipText = [self getEmptyText];
[_emptyView setNeedsLayout];
[_emptyView setNeedsUpdateConstraints];
}
- (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