All Projects → ZionChang → Emptykit

ZionChang / Emptykit

Licence: mit
A lightweight, swift library for displaying emptyView whenever the view(tableView/collectionView) has no content to display, just like DZNEmptyDataSet

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Emptykit

Containercontroller
UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version
Stars: ✭ 273 (+133.33%)
Mutual labels:  xcode, tableview, collectionview
Shsegmentedcontroltableview
Both scroll horizontal and vertical for segment scrollview which have a same header. — 类似半糖、美丽说主页与QQ音乐歌曲列表布局效果,实现不同菜单的左右滑动切换,同时支持类似tableview的顶部工具栏悬停(既可以左右滑动,又可以上下滑动)。兼容下拉刷新,上拉加载更多。现已加入swift豪华套餐,使用样例助你快速使用
Stars: ✭ 259 (+121.37%)
Mutual labels:  tableview, collectionview
Pageable
An easy way to Pagination or Infinite scrolling for TableView/CollectionView
Stars: ✭ 44 (-62.39%)
Mutual labels:  tableview, collectionview
Differencekit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Stars: ✭ 2,986 (+2452.14%)
Mutual labels:  tableview, collectionview
Accordionswift
The best way of implement an accordion menu using an UITableView in Swift
Stars: ✭ 156 (+33.33%)
Mutual labels:  xcode, tableview
Zkcarousel
A simple carousel implementation written in Swift
Stars: ✭ 163 (+39.32%)
Mutual labels:  xcode, collectionview
SNAdapter
iOS swift tableview and collectionView Adapter
Stars: ✭ 35 (-70.09%)
Mutual labels:  tableview, collectionview
Rxasdatasources
RxDataSource for AsyncDisplayKit/Texture
Stars: ✭ 114 (-2.56%)
Mutual labels:  tableview, collectionview
Diffabledatasources
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
Stars: ✭ 601 (+413.68%)
Mutual labels:  tableview, collectionview
Hfcardcollectionviewlayout
The HFCardCollectionViewLayout provides a card stack layout not quite similar like the apps Reminder and Wallet.
Stars: ✭ 281 (+140.17%)
Mutual labels:  xcode, collectionview
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (+6.84%)
Mutual labels:  xcode, tableview
Modelassistant
Elegant library to manage the interactions between view and model in Swift
Stars: ✭ 26 (-77.78%)
Mutual labels:  tableview, collectionview
Reactivelists
React-like API for UITableView & UICollectionView
Stars: ✭ 250 (+113.68%)
Mutual labels:  tableview, collectionview
SectionReactor
A ReactorKit extension for managing table view and collection view sections with RxDataSources
Stars: ✭ 45 (-61.54%)
Mutual labels:  tableview, collectionview
Rxdatasources
UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)
Stars: ✭ 2,784 (+2279.49%)
Mutual labels:  tableview, collectionview
Swipetableview
Both scroll horizontal and vertical for segment scrollview which have a same header. — 类似半糖、美丽说主页与QQ音乐歌曲列表布局效果,实现不同菜单的左右滑动切换,同时支持类似tableview的顶部工具栏悬停(既可以左右滑动,又可以上下滑动)。兼容下拉刷新,自定义 collectionview实现自适应 contentSize 还可实现瀑布流功能
Stars: ✭ 2,252 (+1824.79%)
Mutual labels:  tableview, collectionview
Rxrealmdatasources
An easy way to bind an RxRealm observable to a table or collection view
Stars: ✭ 154 (+31.62%)
Mutual labels:  tableview, collectionview
Fapaginationlayout
Collection view pagination layout
Stars: ✭ 276 (+135.9%)
Mutual labels:  xcode, collectionview
Parallaxheader
Simple way to add parallax header to UIScrollView/UITableView written in Swift.
Stars: ✭ 808 (+590.6%)
Mutual labels:  xcode, tableview
Collectionnode
a collectionView made for Sprite Kit
Stars: ✭ 96 (-17.95%)
Mutual labels:  xcode, collectionview

EmptyKit

A lightweight, swift library for displaying emptyView whenever the view(tableView/collectionView) has no content to display, just like DZNEmptyDataSet

Swift Version Pod Version Carthage compatible License Platform

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift4 (EmptyKit 4.x) Swift3(EmptyKit 3.x)

Installation

Carthage

Create a Cartfile that lists the framework. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/EmptyKit.framework to an iOS project.

github "ZionChang/EmptyKit"

Run carthage update to build the framework and drag the built EmptyKit.framework into your Xcode project.

To get the full benefits import EmptyKit

import EmptyKit

CocoaPods

You can use CocoaPods to install EmptyKit by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'EmptyKit'

Then, run the following command:

$ pod install

Manually

  1. Download and drop Empty in your project.
  2. Congratulations!

Usage

Protocol Conformance

final class DetailTableViewController: UITableViewController { 

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.tableFooterView = UIView()
        tableView.ept.dataSource = self
        tableView.ept.delegate = self
    }

}

Data Source Imp

extension DetailTableViewController: EmptyDataSource {

    func imageForEmpty(in view: UIView) -> UIImage? {
        return UIImage(named: "empty_data_bookshelf")
    }

    func titleForEmpty(in view: UIView) -> NSAttributedString? {
        let title = "no data"
        let font = UIFont.systemFont(ofSize: 14)
        let attributes: [NSAttributedStringKey : Any] = [.foregroundColor: UIColor.black, .font: font]
        return NSAttributedString(string: title, attributes: attributes)
    }

    func buttonTitleForEmpty(forState state: UIControlState, in view: UIView) -> NSAttributedString? {
        let title = "click me"
        let font = UIFont.systemFont(ofSize: 17)
        let attributes: [NSAttributedStringKey : Any] = [.foregroundColor: UIColor.white, .font: font]
        return NSAttributedString(string: title, attributes: attributes)
    }

    func buttonBackgroundColorForEmpty(in view: UIView) -> UIColor {
        return UIColor.blue
    }

}

Or you can implement other methods of EmptyDataSource

Delegate Imp

extension DetailTableViewController: EmptyDelegate {

    func emptyButton(_ button: UIButton, didTappedIn view: UIView) {
        print( #function, #line, type(of: self))
    }

    func emptyView(_ emptyView: UIView, didTapppedIn view: UIView) {
        print( #function, #line, type(of: self))
    }
}

Refresh layout

self.tableView.reloadData()

or

self.collectionView.reloadData()

depending of which you are using.

Force layout update

self.tableView.ept.reloadData()

or

self.collectionView.ept.reloadData()

Global Configuration

  1. Conform EmptyDataSource or EmptyDelegate
protocol ProjectNameEmptyDataSource: EmptyDataSource {}
extension ProjectNameEmptyDataSource {
    // implement any method you want
    func backgroundColorForEmpty(in view: UIView) -> UIColor {
        return UIColor.white
    }
    // other methods
}

protocol ProjectNameEmptyDelegate: EmptyDelegate {}
extension ProjectNameEmptyDelegate {
    // just like the ProjectNameEmptyDataSource
}

final class ProjectNameViewController: UITableViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.tableFooterView = UIView()
        tableView.ept.dataSource = self
        tableView.ept.delegate = self
    }
}
  1. Remember use your custom protocol
extension ProjectNameViewController: ProjectNameEmptyDataSource {}
extension ProjectNameViewController: ProjectNameEmptyDelegate {}

# 中文介绍

要求

  • iOS8.0+
  • Xcode 8.0+

安装

Cathage

首先需要安装Carthage

创建一个Cartfile,在其中列出需要的framework

github "ZionChang/EmptyKit"	

命令行运行carthage update来构建framework,并且将EmptyKit.framework拖拽到Xcode中。

import EmptyKit

CocoaPods

创建Podfile

platform :ios, '8.0'
use_frameworks!
pod 'EmptyKit', '~> 3.0.2'

然后运行

pod install

手动

  1. 下载并且将EmptyKit文件夹拖拽至你的工程
  2. 恭喜!

用法

遵守协议

final class DetailTableViewController: UITableViewController { 

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.tableFooterView = UIView()
        tableView.ept.dataSource = self
        tableView.ept.delegate = self
    }

}

数据源实现

extension DetailTableViewController: EmptyDataSource {

    func imageForEmpty(in view: UIView) -> UIImage? {
        return UIImage(named: "empty_data_bookshelf")
    }

    func titleForEmpty(in view: UIView) -> NSAttributedString? {
        let title = "no data"
        let font = UIFont.systemFont(ofSize: 14)
        let attributes: [NSAttributedStringKey : Any] = [.foregroundColor: UIColor.black, .font: font]
        return NSAttributedString(string: title, attributes: attributes)
    }

    func buttonTitleForEmpty(forState state: UIControlState, in view: UIView) -> NSAttributedString? {
        let title = "click me"
        let font = UIFont.systemFont(ofSize: 17)
        let attributes: [NSAttributedStringKey : Any] = [.foregroundColor: UIColor.white, .font: font]
        return NSAttributedString(string: title, attributes: attributes)
    }

    func buttonBackgroundColorForEmpty(in view: UIView) -> UIColor {
        return UIColor.blue
    }

}

或者你能实现EmptyDataSource中的其他方法

代理实现

extension DetailTableViewController: EmptyDelegate {

    func emptyButton(_ button: UIButton, tappedIn view: UIView) {
        print( #function, #line, type(of: self))
    }

    func emptyView(_ emptyView: UIView, tappedIn view: UIView) {
        print( #function, #line, type(of: self))
    }
}

刷新布局

self.tableView.reloadData()

或者

self.collectionView.reloadData()

强制刷新空视图

self.tableView.ept.reloadData()

或者

self.collectionView.ept.reloadData()

全局配置

  • 遵守EmptyDataSource或者EmptyDelegate
protocol ProjectNameEmptyDataSource: EmptyDataSource {}
extension ProjectNameEmptyDataSource {
    // implement any method you want
    func backgroundColorForEmpty(in view: UIView) -> UIColor {
        return UIColor.white
    }
    // other methods
}

protocol ProjectNameEmptyDelegate: EmptyDelegate {}
extension ProjectNameEmptyDelegate {
    // just like the ProjectNameEmptyDataSource
}

final class ProjectNameViewController: UITableViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.tableFooterView = UIView()
        tableView.ept.dataSource = self
        tableView.ept.delegate = self
    }
}
  • 一旦全局配置,就使用你配置的协议名字
extension ProjectNameViewController: ProjectNameEmptyDataSource {}
extension ProjectNameViewController: ProjectNameEmptyDelegate {}

License

EmptyKit is licensed under the MIT License, please see the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].