#import "HolderView.h" @implementation HolderView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setBackgroundColor:[UIColor whiteColor]]; self.clipsToBounds = YES; CGFloat x,y,w,h; w = h = kSize.width/3.0; x = y = w; y +=64; UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)]; iv.center = CGPointMake(frame.size.width/2, frame.size.height/2-50/2); [iv setImage:[UIImage imageNamed:@"holder.png"]]; [iv setContentMode:UIViewContentModeScaleAspectFit]; [self addSubview:iv]; y = CGRectGetMaxY(iv.frame); x = 0; w = kSize.width; h = 50; UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)]; [label setTextAlignment:NSTextAlignmentCenter]; [label setTextColor:[UIColor darkGrayColor]]; [label setFont:[UIFont systemFontOfSize:18]]; [label setNumberOfLines:0]; [self addSubview:label]; titLabel = label; _title = @"暂无信息~"; } return self; } -(void)layoutSubviews { [super layoutSubviews]; [titLabel setText:_title]; } -(void)freshBlock:(BlockTypeVo)block { fresh = block; if (!btnFul) { UIButton* btn; btn = [[UIButton alloc] initWithFrame:self.bounds]; [self addSubview:btn]; btnFul = btn; _title = [_title stringByAppendingString:@"\n点击刷新"]; [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; } } -(void)btnClick:(UIButton*)sender { if (fresh) { self.hidden = YES; fresh(); } } @end