DZNEmptyDataSet 当没有数据时tableview,collection的显示

DZNEmptyDataSet 使用指南
本文介绍了如何使用 DZNEmptyDataSet 库来自定义空数据集视图的各种元素,包括标题、描述、图片、按钮等,并提供了详细的代码示例。
#import "UIScrollView+EmptyDataSet.h"
<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
    _tableView.emptyDataSetSource = self;
    _tableView.emptyDataSetDelegate = self;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}
#pragma mark - DZNEmptyDataSetSource Methods
/**< 题目 >*/
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
    
    NSMutableDictionary *attribute = [[NSMutableDictionary alloc] init];
    attribute[NSFontAttributeName] = [UIFont systemFontOfSize:20];
    attribute[NSForegroundColorAttributeName] = [UIColor greenColor];
    return [[NSAttributedString alloc] initWithString:@"title title" attributes:attribute];
}

/**< 描述 >*/
- (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView {
    
    NSMutableDictionary *attribute = [[NSMutableDictionary alloc] init];
    attribute[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attribute[NSForegroundColorAttributeName] = [UIColor yellowColor];
    
    /**< 段落 >*/
    NSMutableParagraphStyle *patagraph = [[NSMutableParagraphStyle alloc] init];
    patagraph.lineBreakMode = NSLineBreakByWordWrapping;
    patagraph.alignment = NSTextAlignmentCenter;
    patagraph.lineSpacing = 4.0;
    attribute[NSParagraphStyleAttributeName] = patagraph;
    NSMutableAttributedString *attstr = [[NSMutableAttributedString alloc] initWithString:@"描述性文本,描述信息,描述" attributes:attribute];
    
    return attstr;
    
}
/**< 图片 >*/
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
    return [UIImage imageNamed:@"[白眼]"];
}
/**< 图片填充色 >*/
- (UIColor *)imageTintColorForEmptyDataSet:(UIScrollView *)scrollView {
    return [UIColor blueColor];
}

/**< 图片动画?暂时不知道 >*/
- (CAAnimation *)imageAnimationForEmptyDataSet:(UIScrollView *)scrollView {
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
    animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
    animation.toValue = [NSValue valueWithCATransform3D: CATransform3DMakeRotation(M_PI_2, 0.0, 0.0, 1.0) ];
    animation.duration = 0.25;
    animation.cumulative = YES;
    animation.repeatCount = MAXFLOAT;
    return animation;
}
/**< 按钮,文字 >*/
- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {
    NSMutableDictionary *attribute = [[NSMutableDictionary alloc] init];
    attribute[NSFontAttributeName] = [UIFont systemFontOfSize:15];
    attribute[NSForegroundColorAttributeName] = [UIColor brownColor];
    return [[NSAttributedString alloc] initWithString:@"button title" attributes:attribute];
}

/**< 按钮,图片 >*/
- (UIImage *)buttonBackgroundImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {
    return [UIImage imageNamed:@"[白眼]"];
}
#pragma mark - DZNEmptyDataSetDelegate Methods
/**< 按钮点击事件代理 >*/
- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button {
    
}

 

使用:   pod 'DZNEmptyDataSet', :path => '../../'

一个区的时候可以,两个区以上的??

链接: https://github.com/dzenbot/DZNEmptyDataSet

链接: http://j.news.163.com/docs/99/2015072119/AV2PUI3V9001UI40.html

 

转载于:https://www.cnblogs.com/lyl-/p/4958801.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值