12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #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:@"community4.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:18]];
- [label setTextColor:contentTextColor];
- [label setNumberOfLines:0];
- [self addSubview:label];
- titLabel = label;
-
- _title = @"暂无信息~";
- }
- return self;
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
- [titLabel setText:_title];
-
- titLabel.height = [_title heightForWid:kSize.width Font:18];
- }
- -(void)freshBlock:(BlockTypeVo)block
- {
- fresh = block;
- if (!btnFul) {
- UIButton* btn;
- btn = [[UIButton alloc] initWithFrame:self.bounds];
- [self addSubview:btn];
- btnFul = btn;
- _title = @"点击刷新";
-
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- }
- -(void)btnClick:(UIButton*)sender
- {
- if (fresh) {
- self.hidden = YES;
- fresh();
- }
- }
- @end
|