zoukankan      html  css  js  c++  java
  • iOS 给tableview添加空态页面

    1.导入第三方库

    pod 'DZNEmptyDataSet'

    2.使用

    #import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>
    DZNEmptyDataSetSource, DZNEmptyDataSetDelegate
    //空数据空白
        self.tableView.emptyDataSetSource = self;
        self.tableView.emptyDataSetDelegate = self;
    #pragma mark -- DZNEmptyDataSetSource
    
    - (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView {
        NSString *text = @"暂无未读消息";
        NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
        paragraph.lineBreakMode = NSLineBreakByWordWrapping;
        paragraph.alignment = NSTextAlignmentCenter;
        NSDictionary *attributes = @{
                                     NSFontAttributeName:[UIFont systemFontOfSize:14],
                                     NSForegroundColorAttributeName:UIColorFromRGB(0xB8B8B8),
                                     NSParagraphStyleAttributeName:paragraph
                                     };
        return [[NSAttributedString alloc] initWithString:text attributes:attributes];
    }
    
    - (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView {
        return 25.0f;
    }
    
    //往上偏移64高度
    - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
        return -64;
    }
  • 相关阅读:
    Sum Root to Leaf Numbers 解答
    459. Repeated Substring Pattern
    71. Simplify Path
    89. Gray Code
    73. Set Matrix Zeroes
    297. Serialize and Deserialize Binary Tree
    449. Serialize and Deserialize BST
    451. Sort Characters By Frequency
    165. Compare Version Numbers
    447. Number of Boomerangs
  • 原文地址:https://www.cnblogs.com/qiyiyifan/p/8094534.html
Copyright © 2011-2022 走看看