| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // RAEmptyView.m
- // Apex And Drivers
- //
- // Created by Jack on 2018/9/5.
- // Copyright © 2018年 USAI. All rights reserved.
- //
- #import "RAEmptyView.h"
- @interface RAEmptyView ()
- @property (nonatomic,copy) void(^tapEmptyBlk)(id sender);
- @property (nonatomic,strong) UILabel *tipLabel;
- @end
- @implementation RAEmptyView
- + (instancetype)emptyViewWithTapBlk:(void(^)(id sender))tapEmptyBlk {
- RAEmptyView *emptyView = [RAEmptyView new];
- emptyView.frame = CGRectMake(0, 0, 200, 80);
- emptyView.tapEmptyBlk = tapEmptyBlk;
-
- return emptyView;
- }
- - (instancetype)init {
-
- if (self = [super init]) {
- self.layer.borderColor = [UIColor grayColor].CGColor;
- self.layer.borderWidth = 0.5f;
- self.layer.cornerRadius = 5.0f;
- self.layer.masksToBounds = YES;
- [self addSubview:self.tipLabel];
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapEmpty:)];
- [self addGestureRecognizer:tap];
- }
- return self;
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
-
- self.tipLabel.frame = self.bounds;
- }
- - (UILabel *)tipLabel {
- if (!_tipLabel) {
- _tipLabel = [[UILabel alloc] init];
- _tipLabel.text = @"There is no data\nPlease click to reload";
- _tipLabel.numberOfLines = 0;
- _tipLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _tipLabel;
- }
- - (void)tapEmpty:(UITapGestureRecognizer *)tap {
- if (self.tapEmptyBlk) {
- self.tapEmptyBlk(tap);
- }
- }
- @end
|