UITableView和UICollectionView显示空白页的框架

DFEmpty

本框架是基于DZNEmptyDataSet写的,在使用DZNEmptyDataSet时如果列表的ContentSize比较大的时候,显示的空白页位置会偏移很多,一直不知道怎么解决,所以自己基于DZNEmptyDataSet写了DFEmpty。

使用pod导入

pod 'DFEmpty'

使用方法

#import "UIScrollView+EmptyData.h"

协议

<DFEmptyDataSetSource, DFEmptyDataSetDelegate>
self.tableView.emptyDataSetSource = self;
self.tableView.emptyDataSetDelegate = self;

DFEmptyDataSetSource

/**
 * 空白页标题
 */
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView;
/**
 * 空白页描述
 */
- (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView;
/**
 * 空白页图片
 */
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView;
/**
 * 空白页图片动画
 */
- (CAAnimation *)imageAnimationForEmptyDataSet:(UIScrollView *)scrollView;
/**
 * 空白页按钮标题
 */
- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state;
/**
 * 空白页按钮图片
 */
- (UIImage *)buttonImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state;
/**
 * 空白页按钮背景图片
 */
- (UIImage *)buttonBackgroundImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state;

/**
 * 返回自定义的空白页
 */
- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView;

/**
 * 垂直偏移
 */
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView;

/**
 * 空白页中元素之间的空隙,默认11
 */
- (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView;

DFEmptyDataSetDelegate

/**
 * 空白页userInteractionEnabled是否有效,默认YES
 */
- (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView;

/**
 * 默认空白页是否有动画效果
 */
- (BOOL)emptyDataSetShouldAnimateImageView:(UIScrollView *)scrollView;
/**
 * 点击空白页回调
 */
- (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view;
/**
 * 点击按钮回调
 */
- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button;

最后附上Demo地址

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 因为要结局swift3.0中引用snapKit的问题,看到一篇介绍Xcode8,swift3变化的文章,觉得很详细...
    uniapp阅读 4,490评论 0 12
  • 01 又一个大学同学生病了。“恶性....”,是个什么鬼?我不知道。在人间,病与治病是一对魔与道,纠缠不清,相...
    乐菁莪阅读 595评论 4 5
  • 今天中午跟同事吃饭的时候聊天,身为班主任的她说:“感觉自己这学期的教学水平一点都没提高,光管理班级去了。”我说:“...
    半夜花开阅读 527评论 0 6
  • 努力,潜伏,蛰伏,早晚会让你高看我
    心情随笔jing阅读 190评论 0 0
  • 根本无为又贪痴, 得过且过度荒日。 可笑晴天做美梦, 还想娇花嫁枯枝。
    松风入骨阅读 543评论 24 28