40 lines
1.5 KiB
Objective-C
40 lines
1.5 KiB
Objective-C
//
|
||
// UIScrollView+KBEmptyView.h
|
||
// keyBoard
|
||
//
|
||
// 统一封装基于 LYEmptyView 的空态视图挂载方法,适用于 UITableView/UICollectionView。
|
||
//
|
||
|
||
#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
|
||
|