Latest 0.0.1
Homepage https://github.com/seongbrave/EmptyDataView
License MIT
Platforms ios 8.0
Dependencies RxSwift, RxCocoa, SnapKit
Authors

EmptyDataView是处理UITableView和UIcollectionview列表为空时自定义展示空界面

预览

使用要求

  • Xcode 9.0+

安装

CocoaPods

pod 'EmptyDataView', '~> 0.0.1'

具体使用

UITableView

设置代理

     test_Tv.dzn_tv_emptyDataSource = self
     test_Tv.dzn_tv_emptyDelegate = self
     /// tableview 需要设置tableFooterView
     test_Tv.tableFooterView = UIView()

代理实现

EmptyDataSource

extension Test_TVc:EmptyDataSource{
    /**
     配置空数据时显示的副标题(描述)

     - Parameter scrollView: 目标视图

     - Returns: 副标题(描述)

     */
    func description(emptyView scrollView: UIScrollView) -> NSAttributedString? {
        var attributes: [NSAttributedStringKey:Any] = [:]
        attributes[NSAttributedStringKey.font] = UIFont.systemFont(ofSize: 17)
        attributes[NSAttributedStringKey.foregroundColor] = UIColor.red
        let paragraph = NSMutableParagraphStyle()
        paragraph.alignment = .center
        attributes[NSAttributedStringKey.paragraphStyle] = paragraph
        let attributedString =  NSMutableAttributedString(string: "商品列表数据为空啊", attributes: nil)
        let range = (attributedString.string as NSString).range(of: "列表数据")
        attributedString.addAttributes([NSAttributedStringKey.foregroundColor: #colorLiteral(red: 0, green: 0.6784313725, blue: 0.9450980392, alpha: 1)], range: range)
        return attributedString
    }
}

EmptyDelegate

extension Test_TVc :EmptyDelegate{
    /**
     配置是否允许显示空视图

     - Parameter scrollView: 目标视图

     - Returns:  是否显示
     - true 显示 (default)
     - false 不显示

     */
     func shouldDisplay(emptyView scrollView: UIScrollView) -> Bool{
        return true
    }
     func didTap(emptyView scrollView: UIScrollView, button: UIButton){

    }
}

UICollectionView

设置代理

    self.test_Cv.dzn_Cv_emptyDelegate = self
    self.test_Cv.dzn_Cv_emptyDataSource = self

代理实现

EmptyDataSource

extension Test_CVc:EmptyDataSource{
    /**
     配置空数据时显示的副标题(描述)

     - Parameter scrollView: 目标视图

     - Returns: 副标题(描述)

     */
    func description(emptyView scrollView: UIScrollView) -> NSAttributedString? {
        var attributes: [NSAttributedStringKey:Any] = [:]
        attributes[NSAttributedStringKey.font] = UIFont.systemFont(ofSize: 17)
        attributes[NSAttributedStringKey.foregroundColor] = UIColor.red
        let paragraph = NSMutableParagraphStyle()
        paragraph.alignment = .center
        attributes[NSAttributedStringKey.paragraphStyle] = paragraph
        let attributedString =  NSMutableAttributedString(string: "商品列表数据为空啊", attributes: nil)
        let range = (attributedString.string as NSString).range(of: "列表数据")
        attributedString.addAttributes([NSAttributedStringKey.foregroundColor: #colorLiteral(red: 0, green: 0.6784313725, blue: 0.9450980392, alpha: 1)], range: range)
        return attributedString
    }

}

EmptyDelegate

extension Test_CVc :EmptyDelegate{
    /**
     配置是否允许显示空视图

     - Parameter scrollView: 目标视图

     - Returns:  是否显示
     - true 显示 (default)
     - false 不显示

     */
     func shouldDisplay(emptyView scrollView: UIScrollView) -> Bool{
        return true
    }
     func didTap(emptyView scrollView: UIScrollView, button: UIButton){

    }
}

Latest podspec

{
    "name": "EmptyDataView",
    "version": "0.0.1",
    "summary": "TableViewu4e0eCollectionviewu7a7au6570u636eu65f6u663eu793au7684view",
    "description": "TODO: uitableview u6216uicollectionview u4e3au7a7au7684u754cu9762u663eu793a",
    "homepage": "https://github.com/seongbrave/EmptyDataView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "seongbrave": "[email protected]"
    },
    "source": {
        "git": "https://github.com/seongbrave/EmptyDataView.git",
        "tag": "0.0.1"
    },
    "social_media_url": "http://seongbrave.github.io/",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "EmptyDataView/Classes/**/*",
    "dependencies": {
        "RxSwift": [
            "~> 4.1.2"
        ],
        "RxCocoa": [
            "~> 4.1.2"
        ],
        "SnapKit": [
            "~> 4.0.0"
        ]
    }
}

Pin It on Pinterest

Share This