All Projects → Xiaoye220 → Emptydataset Swift

Xiaoye220 / Emptydataset Swift

Licence: mit
🎄 DZNEmptyDataSet implement with Swift.A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display. DZNEmptyDataSet with Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Emptydataset Swift

XLRefresh
iOS 下拉刷新工具
Stars: ✭ 25 (-94.36%)
Mutual labels:  uitableview, uicollectionview
Owl
A declarative type-safe framework for building fast and flexible lists with UITableViews & UICollectionViews
Stars: ✭ 423 (-4.51%)
Mutual labels:  uicollectionview, uitableview
CollectionAndTableViewCompatible
A set of Swift protocols and Xcode snippets that will make it easy to do clean UITableView code
Stars: ✭ 34 (-92.33%)
Mutual labels:  uitableview, uicollectionview
ios ui recipe showcase
iOSアプリ開発 - UI実装であると嬉しいレシピブック掲載サンプル
Stars: ✭ 54 (-87.81%)
Mutual labels:  uitableview, uicollectionview
Baraba
Make your UIScrollView scroll automatically when user is looking 👀 by tracking face using ARKit and AVFoundation
Stars: ✭ 268 (-39.5%)
Mutual labels:  uicollectionview, uitableview
Transfiguration
Mystical way to transform data into reusable view in Swift
Stars: ✭ 14 (-96.84%)
Mutual labels:  uitableview, uicollectionview
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Stars: ✭ 3,395 (+666.37%)
Mutual labels:  uicollectionview, uitableview
PagedLists
Paginated UITableView and UICollectionViews for iOS.
Stars: ✭ 69 (-84.42%)
Mutual labels:  uitableview, uicollectionview
iOSEasyList
A data-driven UICollectionView and UITableView framework for building fast and flexible lists
Stars: ✭ 29 (-93.45%)
Mutual labels:  uitableview, uicollectionview
WBListKit
A data-driven UICollectionView&UITableView framework for building fast and flexible lists by declarative syntax.
Stars: ✭ 32 (-92.78%)
Mutual labels:  uitableview, uicollectionview
Uitableviewdynamiclayoutcacheheight
🖖高性能的自动计算采用 Autolayout 布局的 UITableViewCell 和 UITableViewHeaderFooterView 的高度,内部自动管理高度缓存。
Stars: ✭ 360 (-18.74%)
Mutual labels:  uicollectionview, uitableview
Livecollections
Automatically perform UITableView and UICollectionView animations between two sets of immutable data. It supports generic data types and is fully thread-safe.
Stars: ✭ 337 (-23.93%)
Mutual labels:  uicollectionview, uitableview
GenericCells
Creating generic UITableViewCells and UICollectionViewCells instead of subclasses.
Stars: ✭ 81 (-81.72%)
Mutual labels:  uitableview, uicollectionview
Functionaltabledata
Declarative UITableViewDataSource implementation
Stars: ✭ 347 (-21.67%)
Mutual labels:  uicollectionview, uitableview
TinyCoordinator
The Swift version of ThinningCoordinator focus on lighter view controllers.
Stars: ✭ 18 (-95.94%)
Mutual labels:  uitableview, uicollectionview
Lpdmvvmkit
LPDMvvmKit - Elegant MVVM framework in Objective-C.
Stars: ✭ 400 (-9.71%)
Mutual labels:  uicollectionview, uitableview
Cyanic
Declarative, state-driven UI framework
Stars: ✭ 32 (-92.78%)
Mutual labels:  uitableview, uicollectionview
HDEmptyView
一个Swift语言封装的EmptyView显示库,可作用于WKWebView、UITableView、UICollectionView 无网络提醒或者空数据提醒
Stars: ✭ 29 (-93.45%)
Mutual labels:  uitableview, uicollectionview
MultiSelect
swift
Stars: ✭ 12 (-97.29%)
Mutual labels:  uitableview, uicollectionview
Wlemptystate
WLEmptyState is an iOS based component that lets you customize the view when the dataset of a UITableView or a UICollectionView is empty. We created a sample project with the WLEmptyState component to show how you can use it.
Stars: ✭ 305 (-31.15%)
Mutual labels:  uicollectionview, uitableview

EmptyDataSet-Swift

pod Carthage compatible iOS lisence swift

A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display. DZNEmptyDataSet with Swift.

ScreenShot

Screenshots_row1

Screenshots_row2

Installation

CocoaPods

pod 'EmptyDataSet-Swift', '~> 5.0.0'

Carthage

github "Xiaoye220/EmptyDataSet-Swift" "4.2.0"

Usage

Basic

Same as DZNEmptyDataSet

import EmptyDataSet_Swift

class OriginalUsageViewController: UITableViewController, EmptyDataSetSource, EmptyDataSetDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        tableView.emptyDataSetSource = self
        tableView.emptyDataSetDelegate = self
    }
}

EmptyDataSetDelegate

public protocol EmptyDataSetDelegate: class {

    /// Asks the delegate to know if the empty dataset should fade in when displayed. Default is true.
    func emptyDataSetShouldFadeIn(_ scrollView: UIScrollView) -> Bool
    
    /// Asks the delegate to know if the empty dataset should still be displayed when the amount of items is more than 0. Default is false.
    func emptyDataSetShouldBeForcedToDisplay(_ scrollView: UIScrollView) -> Bool

    /// Asks the delegate to know if the empty dataset should be rendered and displayed. Default is true.
    func emptyDataSetShouldDisplay(_ scrollView: UIScrollView) -> Bool

    /// Asks the delegate for touch permission. Default is true.
    func emptyDataSetShouldAllowTouch(_ scrollView: UIScrollView) -> Bool

    /// Asks the delegate for scroll permission. Default is false.
    func emptyDataSetShouldAllowScroll(_ scrollView: UIScrollView) -> Bool

    /// Asks the delegate for image view animation permission. Default is false.
    /// Make sure to return a valid CAAnimation object from imageAnimationForEmptyDataSet:
    func emptyDataSetShouldAnimateImageView(_ scrollView: UIScrollView) -> Bool

    /// Tells the delegate that the empty dataset view was tapped.
    /// Use this method either to resignFirstResponder of a textfield or searchBar.
    func emptyDataSet(_ scrollView: UIScrollView, didTapView view: UIView)

    /// Tells the delegate that the action button was tapped.
    func emptyDataSet(_ scrollView: UIScrollView, didTapButton button: UIButton)

    /// Tells the delegate that the empty data set will appear.
    func emptyDataSetWillAppear(_ scrollView: UIScrollView)

    /// Tells the delegate that the empty data set did appear.
    func emptyDataSetDidAppear(_ scrollView: UIScrollView)

    /// Tells the delegate that the empty data set will disappear.
    func emptyDataSetWillDisappear(_ scrollView: UIScrollView)

    /// Tells the delegate that the empty data set did disappear.
    func emptyDataSetDidDisappear(_ scrollView: UIScrollView)
}

EmptyDataSetSource

public protocol EmptyDataSetSource: class {

    /// Asks the data source for the title of the dataset.
    /// The dataset uses a fixed font style by default, if no attributes are set. If you want a different font style, return a attributed string.
    func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString?
    
    /// Asks the data source for the description of the dataset.
    /// The dataset uses a fixed font style by default, if no attributes are set. If you want a different font style, return a attributed string.
    func description(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString?
    
    /// Asks the data source for the image of the dataset.
    func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage?
    
    /// Asks the data source for a tint color of the image dataset. Default is nil.
    func imagetintColor(forEmptyDataSet scrollView: UIScrollView) -> UIColor?

    /// Asks the data source for the image animation of the dataset.
    func imageAnimation(forEmptyDataSet scrollView: UIScrollView) -> CAAnimation?
    
    /// Asks the data source for the title to be used for the specified button state.
    /// The dataset uses a fixed font style by default, if no attributes are set. If you want a different font style, return a attributed string.
    func buttonTitle(forEmptyDataSet scrollView: UIScrollView, for state: UIControl.State) -> NSAttributedString?
    
    /// Asks the data source for the image to be used for the specified button state.
    /// This method will override buttonTitleForEmptyDataSet:forState: and present the image only without any text.
    func buttonImage(forEmptyDataSet scrollView: UIScrollView, for state: UIControl.State) -> UIImage?
    
    /// Asks the data source for a background image to be used for the specified button state.
    /// There is no default style for this call.
    func buttonBackgroundImage(forEmptyDataSet scrollView: UIScrollView, for state: UIControl.State) -> UIImage?

    /// Asks the data source for the background color of the dataset. Default is clear color.
    func backgroundColor(forEmptyDataSet scrollView: UIScrollView) -> UIColor?

    /// Asks the data source for a custom view to be displayed instead of the default views such as labels, imageview and button. Default is nil.
    /// Use this method to show an activity view indicator for loading feedback, or for complete custom empty data set.
    /// Returning a custom view will ignore -offsetForEmptyDataSet and -spaceHeightForEmptyDataSet configurations.
    func customView(forEmptyDataSet scrollView: UIScrollView) -> UIView?

    /// Asks the data source for a offset for vertical alignment of the content. Default is 0.
    func verticalOffset(forEmptyDataSet scrollView: UIScrollView) -> CGFloat

    /// Asks the data source for a vertical space between elements. Default is 11 pts.
    func spaceHeight(forEmptyDataSet scrollView: UIScrollView) -> CGFloat
}

Extensions

Usage without conform to datasource and/or delegate.Tableview just calls the following method.

public func emptyDataSetView(_ closure: @escaping (EmptyDataSetView) -> Void)

Example:

tableView.emptyDataSetView { view in
    view.titleLabelString(titleString)
        .detailLabelString(detailString)
        .image(image)
        .imageAnimation(imageAnimation)
        .buttonTitle(buttonTitle, for: .normal)
        .buttonTitle(buttonTitle, for: .highlighted)
        .buttonBackgroundImage(buttonBackgroundImage, for: .normal)
        .buttonBackgroundImage(buttonBackgroundImage, for: .highlighted)
        .dataSetBackgroundColor(backgroundColor)
        .verticalOffset(verticalOffset)
        .verticalSpace(spaceHeight)
        .shouldDisplay(true, view: tableView)
        .shouldFadeIn(true)
        .isTouchAllowed(true)
        .isScrollAllowed(true)
        .isImageViewAnimateAllowed(isLoading)
        .didTapDataButton {
            // Do something
        }
        .didTapContentView {
            // Do something
        }
}

About CustomView

Set customView by using EmptyDataSetSource, other setting will be invalid.Set customView by using Extensions, other autolayout will be invalid.

Rule for displaying CustomView

  1. CustomView will Display in the center of tableView
  2. The verticalOffset of customView can be setted by func verticalOffset(forEmptyDataSet scrollView: UIScrollView) -> CGFloat
  3. The width and height is equel to the frame of customView.But if the customView is UILabel and it's frame is CGRect.zero,it's width and height will be autolayout by it's content.

Example:

Rule 1

func customView(forEmptyDataSet scrollView: UIScrollView) -> UIView? {
    let view = CustomView(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
    return view
}
tableView.emptyDataSetView { [weak self] view in
    view.customView(CustomView(frame: CGRect(x: 0, y: 0, width: 150, height: 150)))
}

above code will show as follows

CustomScreenShot_1

Rule 2

func customView(forEmptyDataSet scrollView: UIScrollView) -> UIView? {
    let view = CustomView(frame: CGRect(x: 0, y: 0, width: 150, height: 150))
    return view
}
func verticalOffset(forEmptyDataSet scrollView: UIScrollView) -> CGFloat {
    return 200
}
tableView.emptyDataSetView { [weak self] view in
    view.customView(CustomView(frame: CGRect(x: 0, y: 0, width: 150, height: 150)))
        .verticalOffset(200)
}

above code will show as follows

CustomScreenShot_2

Rule 3

func customView(forEmptyDataSet scrollView: UIScrollView) -> UIView? {
    let label = UILabel()
    label.text = "CustomView"
    label.backgroundColor = UIColor.red
    return label
}

above code will show as follows

CustomScreenShot_3

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].