This commit is contained in:
2025-11-09 21:41:35 +08:00
parent 2415e97c97
commit 5e1a1f540e
9 changed files with 289 additions and 38 deletions

View File

@@ -13,6 +13,15 @@
#define KB_HAS_DZN 0
#endif
// LYEmptyView Pod +
#if __has_include(<LYEmptyView/UIView+Empty.h>)
#import <LYEmptyView/UIView+Empty.h>
#import <LYEmptyView/LYEmptyView.h>
#define KB_HAS_LY 1
#else
#define KB_HAS_LY 0
#endif
@interface BaseTableView ()
#if KB_HAS_DZN
<DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
@@ -127,4 +136,66 @@
#endif
// MARK: - LYEmptyView DZN
- (void)kb_makeDefaultEmptyViewWithImage:(UIImage *)image
title:(NSString *)title
detail:(NSString *)detail
buttonTitle:(NSString *)buttonTitle
tapHandler:(KBEmptyAction)tapHandler
buttonHandler:(KBEmptyAction)buttonHandler {
#if KB_HAS_LY
// DZN
self.useEmptyDataSet = NO;
//
NSString *t = title ?: @"暂无数据";
LYEmptyView *ev = nil;
if (buttonTitle.length > 0) {
// block
__weak typeof(self) weakSelf = self;
ev = [LYEmptyView emptyActionViewWithImage:image
titleStr:t
detailStr:detail ?: @""
btnTitleStr:buttonTitle
btnClickBlock:^{ if (buttonHandler) buttonHandler(); [weakSelf setNeedsLayout]; }];
} else {
//
ev = [LYEmptyView emptyViewWithImage:image titleStr:t detailStr:detail ?: @""];
}
//
if (tapHandler) {
ev.tapEmptyViewBlock = ^{ tapHandler(); };
}
//
ev.emptyViewIsCompleteCoverSuperView = NO; //
ev.ignoreContentInset = YES; // inset/
ev.contentViewOffset = -10; //
ev.subViewMargin = 14; //
ev.titleLabFont = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
ev.titleLabTextColor = [UIColor colorWithWhite:0.45 alpha:1.0];
ev.detailLabFont = [UIFont systemFontOfSize:14];
ev.detailLabTextColor = [UIColor colorWithWhite:0.6 alpha:1.0];
ev.detailLabLineSpacing = 3;
ev.detailLabMaxLines = 2;
ev.actionBtnFont = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
ev.actionBtnCornerRadius = 6;
ev.actionBtnBorderWidth = 1;
ev.actionBtnBorderColor = [UIColor colorWithWhite:0.88 alpha:1.0];
ev.actionBtnTitleColor = [UIColor colorWithRed:0.22 green:0.49 blue:0.96 alpha:1.0];
ev.actionBtnBackGroundColor = [UIColor whiteColor];
ev.actionBtnHorizontalMargin = 20; // + padding*2
//
ev.autoShowEmptyView = NO;
self.ly_emptyView = (LYEmptyView *)ev;
#else
// LYEmptyView
(void)image; (void)title; (void)detail; (void)buttonTitle; (void)tapHandler; (void)buttonHandler;
#endif
}
@end