纯粹是为了粘代码方便而已
DZNEmptyDataSetSource,DZNEmptyDataSetDelegate
#pragma mark -
#pragma mark - 👉 DZNEmptyDataSetSource 👈
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView {
return YES;
}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
return -120;
}
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
return kIconNamed(@"card_bag_invalid_card_img");
}
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
NSString *title = NSLocalizedString(@"暂时没有失效的卡", nil);
NSDictionary *attributes = @{
NSFontAttributeName:[UIFont dy_font14pt:DYFontBoldTypeRegular],
NSForegroundColorAttributeName:[UIColor colorC5]
};
return [[NSAttributedString alloc] initWithString:title attributes:attributes];
}
#pragma mark -
#pragma mark - 👉 DZNEmptyDataSetSource 👈
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
return kIconNamed(@"bill_consume_img_record");
}
- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {
NSString *text = @"没有找到相关记录,查看更多请 选择时间";
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text];
// 设置所有字体大小为 #15
[attStr addAttribute:NSFontAttributeName
value:[UIFont dy_font12pt:DYFontBoldTypeRegular]
range:NSMakeRange(0, text.length)];
// 设置所有字体颜色为浅灰色
[attStr addAttribute:NSForegroundColorAttributeName
value:[UIColor colorC5]
range:NSMakeRange(0, text.length)];
// 设置指定4个字体为蓝色
[attStr addAttribute:NSForegroundColorAttributeName
value:[UIColor colorC1]
range:NSMakeRange(15, 4)];
return attStr;
}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
return -120.0f;
}
#pragma mark -
#pragma mark - 👉 DZNEmptyDataSetDelegate 👈
- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button {
[self showDatePickerController];
}
- (void)emptyDataSetWillAppear:(UIScrollView *)scrollView {
self.tableView.contentOffset = CGPointZero;
}
_tableView.emptyDataSetDelegate = self;
_tableView.emptyDataSetSource = self;
网友评论