1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #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;
- UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- iv.center = CGPointMake(frame.size.width/2, frame.size.height/2-40);
- [iv setImage:[UIImage imageNamed:@"holder.png"]];
- [iv setContentMode:UIViewContentModeScaleAspectFit];
- [self addSubview:iv];
-
- y = CGRectGetMaxY(iv.frame);
- x = 0;
- w = kSize.width;
- h = 40 * 2;
- UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [label setTextAlignment:NSTextAlignmentCenter];
- [label setFont:[UIFont scaleSize:Font18]];
- [label setTextColor:contentTextColor];
- [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
|