您的位置:首页 > 其它

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

2015-11-12 14:02 543 查看
#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: