DZNEmptyData设置

#import "UIScrollView+EmptyDataSet.h"
遵守代理和数据源方法()

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"贷款订单";
    self.view.backgroundColor = mainWhiteColor;
    [self creatLoanOrderListView];
}
- (void)creatLoanOrderListView{
    _orderDataArr = [[NSMutableArray alloc] init];
    self.orderTableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, mainScreenW, mainScreenH - STATUS_AND_NAVIGATION_HEIGHT) style:UITableViewStylePlain];
    self.orderTableview.delegate = self;
    self.orderTableview.dataSource = self;
    self.orderTableview.emptyDataSetSource = self;
    self.orderTableview.emptyDataSetDelegate = self;
    self.orderTableview.tableFooterView = [UIView new];
    self.orderTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.orderTableview];
    self.orderTableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
    self.orderTableview.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefershDta)];
}


/**************DZNEmptyDataSetSource***********/
/**
 * 返回空的图片
 */
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
    return [UIImage imageNamed:@"empty_placeholder"];
}
/**
 * 标题文字
 */
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
    NSString *text = @"Please Allow Photo Access";
    
    NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:18.0f],
                                 NSForegroundColorAttributeName: [UIColor darkGrayColor]};
    return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
/**
 * 详情文字
 */
- (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView
{
    NSString *text = @"This allows you to share photos from your library and save photos to your camera roll.";
    
    NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
    paragraph.lineBreakMode = NSLineBreakByWordWrapping;
    paragraph.alignment = NSTextAlignmentCenter;
    
    NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f],
                                 NSForegroundColorAttributeName: [UIColor lightGrayColor],
                                 NSParagraphStyleAttributeName: paragraph};
    return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
/**
 * 文字按钮
 */
- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state
{
    NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:17.0f]};
    
    return [[NSAttributedString alloc] initWithString:@"Continue" attributes:attributes];
}
/**
 *  返回图片按钮
 */
- (UIImage *)buttonImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state
{
    return [UIImage imageNamed:@"button_image"];
}
/**
 *  自定义背景颜色
 */
- (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView
{
    return [UIColor whiteColor];
}
/**
 *  返回一个自定义的View
 */
- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView
{
    UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [activityView startAnimating];
    return activityView;
}
/**
 *  返回动画
 */
- (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;
}
/**
 *  设置图片和文字垂直方向的偏移量
 */
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView
{
    return -self.orderTableview.tableHeaderView.frame.size.height/2.0f;
}
/**
 *  设置图片和文字之间的垂直间距
 */
- (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView
{
    return -64.0f;
}
#pragma mark - DZNEmptyDataSetDelegate Methods
/**
 *  数据源为空时候是否渲染和显示(默认为YES);
 */
- (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView
{
    return YES;
}
/**
 *  是否允许点击(默认为YES);
 */
- (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView
{
    return YES;
}
/**
 *  是否允许滚动(默认为NO);
 */
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
{
    return NO;
}
/**
 *  空白区域点击事件;
 */
- (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view
{
    NSLog(@"%s",__FUNCTION__);
}
/**
 *  按钮点击事件;
 */
- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button
{
    
    UISearchBar *searchBar = self.searchDisplayController.searchBar;
    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.com/apps/%@", searchBar.text]];
    if ([[UIApplication sharedApplication] canOpenURL:URL]) {
        [[UIApplication sharedApplication] openURL:URL];
    }
}

你可能感兴趣的:(DZNEmptyData设置)