// // 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]; NSString *tips = NSLocalizedString(@"empty_tips", nil); if ([tips isEqualToString:@"empty_tips"]) { tips = @"Reload"; } _tipLabel.text = tips; _tipLabel.numberOfLines = 0; _tipLabel.textAlignment = NSTextAlignmentCenter; } return _tipLabel; } - (void)tapEmpty:(UITapGestureRecognizer *)tap { if (self.tapEmptyBlk) { self.tapEmptyBlk(tap); } } @end