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

@@ -0,0 +1,40 @@
//
// UIScrollView+KBEmptyView.h
// keyBoard
//
// 统一封装基于 LYEmptyView 的空态视图挂载方法,适用于 UITableView/UICollectionView。
// 注意:仅在对应页面已通过 CocoaPods 集成 LYEmptyView 时生效。
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^KBEmptyAction)(void);
@interface UIScrollView (KBEmptyView)
/// 快速挂载一套统一样式的空态视图LYEmptyView
/// - Parameters:
/// - image: 占位图(可空)
/// - title: 标题(默认“暂无数据”)
/// - detail: 描述(可空)
/// - buttonTitle: 按钮标题(可空,传空则不显示按钮)
/// - tapHandler: 点击空白区域回调(可空)
/// - buttonHandler: 按钮点击回调(可空)
- (void)kb_makeDefaultEmptyViewWithImage:(nullable UIImage *)image
title:(nullable NSString *)title
detail:(nullable NSString *)detail
buttonTitle:(nullable NSString *)buttonTitle
tapHandler:(nullable KBEmptyAction)tapHandler
buttonHandler:(nullable KBEmptyAction)buttonHandler;
/// 便捷加载态控制:关闭自动显隐后,配合网络请求手动控制显示/隐藏
- (void)kb_setLYAutoShowEnabled:(BOOL)enabled; // YES=自动显隐NO=手动
- (void)kb_beginLoadingForEmpty; // 请求开始:临时隐藏 empty
- (void)kb_endLoadingForEmpty; // 请求结束:根据数据源显示/隐藏(需确保先 reloadData
@end
NS_ASSUME_NONNULL_END