DZNEmptyDataSet空白Tableview背景的使用

DZNEmptyDataSet 简单的来说就是用来管理我们tableview数据源为空的时候需要展示什么的一个很强大的控件,废话不多说先上效果图:


首先你要设置一下代理:

_tableView.emptyDataSetSource = self;
_tableView.emptyDataSetDelegate = self;

记得要服从协议 <DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>

下面是代理方法:


#define kFont_MainRegularWithSize(fontSize) [UIFont fontWithName:kFont_PingFangSCRegular size:fontSize]

#pragma mark ----------  DZNEmptyDataSetSource & DZNEmptyDataSetDelegate ----------
// 这里是你文字需要展示什么就写什么就可以了
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {

    NSString *title = @"暂无订单";

    NSDictionary *attributes = @{NSFontAttributeName:kFont_MainRegularWithSize(14),NSForegroundColorAttributeName:

kColor_HexString(@"#666666")};

    return [[NSAttributedString alloc] initWithString:title attributes:attributes];
}

- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
    return -90;
}

// 这是图片 文字 和 button的间距
- (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView {
    return 40;
}

// 这里是你需要显示的大图是就放一个本地的路径就可以了
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
    return [UIImage imageNamed:@"myorder_kongdingdan"];
}

- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {

    NSString *buttonTitle = @"返回首页";   

NSDictionary *attributes = @{NSFontAttributeName:kFont_MainRegularWithSize(18),NSForegroundColorAttributeName:kColor_HexString(@"#F5F5F9")};

    
    return [[NSAttributedString alloc] initWithString:buttonTitle attributes:attributes];
}

- (nullable UIImage *)buttonBackgroundImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {
    
    NSString *imageName = [[NSString stringWithFormat:@"mineorder_backgroundbutton"] lowercaseString];
    UIEdgeInsets capInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    UIEdgeInsets rectInsets = UIEdgeInsetsZero;

    UIImage *image = [UIImage imageNamed:imageName inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];

    return [[image resizableImageWithCapInsets:capInsets resizingMode:UIImageResizingModeStretch] imageWithAlignmentRectInsets:rectInsets];
    
}

- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button {
    
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值