DZNEmptyDataSet 简单使用

  1. 添加依赖
    pod 'DZNEmptyDataSet'
  1. 引入头文件
#import "UIScrollView+EmptyDataSet.h"
  1. 实现接口
<DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  1. 设置代理
//空布局代理
  _tableView.emptyDataSetSource = self;
  _tableView.emptyDataSetDelegate = self;
  1. 实现方法
#pragma mark DZNEmptyDataSet  (当没有数据的时候设置背景颜色)
- (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView
{
    return [UIColor colorWithHexString:@"#F2F3F7"];
}
#pragma mark DZNEmptyDataSet 返回展示空布局的图片
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
    return [UIImage imageNamed:@"empty_icon"];
}

#pragma mark DZNEmptyDataSet  (返回标题)
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
    NSString *text = @"哦哦~暂无数据";
    UIFont *font = [UIFont systemFontOfSize:16];
    UIColor *color = [UIColor colorWithHexString:@"#999999"];
    NSMutableDictionary *attribult = [NSMutableDictionary new];
    [attribult setObject:font forKey:NSFontAttributeName];
    [attribult setObject:color forKey:NSForegroundColorAttributeName];
    return [[NSAttributedString alloc] initWithString:text attributes:attribult];
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容