Giter Club home page Giter Club logo

swiftspreadsheet's Introduction

SwiftSpreadsheet

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Swift 3.0 or newer.

Installation

SwiftSpreadsheet is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SwiftSpreadsheet"

Demo

Output sample

Quick start

A short introduction on how to get started:

The rows of the spreadsheet represent a section in the collection view, with columns being the respective items. The leftmost and the rightmost elements of the spreadsheet (LeftRowHeadline and RightRowHeadline), as well as the topmost and the bottommost elements (TopColumnHeader and BottomColumnFooter) are represented as UISupplementaryView, which โ€” if needed โ€” have to be registered with the respective identifiers of the provided enum ViewKindType (refer to the example code).

The corners of the resulting spreadsheet are represented as UIDecorationView which can be passed as UINib upon initialization of the Layout.

A short example:

//Register SupplementaryViews first, then initialize the layout with optional Nibs for the DecorationViews
let layout = SpreadsheetLayout(delegate: self,
                               topLeftDecorationViewNib: topLeftDecorationViewNib,
                               topRightDecorationViewNib: topRightDecorationViewNib,
                               bottomLeftDecorationViewNib: bottomLeftDecorationViewNib,
                               bottomRightDecorationViewNib: bottomRightDecorationViewNib)

//Default is true, set false here if you do not want some of these sides to remain sticky
layout.stickyLeftRowHeader = true
layout.stickyRightRowHeader = true
layout.stickyTopColumnHeader = true
layout.stickyBottomColumnFooter = true

self.collectionView.collectionViewLayout = layout

Implement the provided SpreadsheetLayoutDelegate. The methods are straightforward. Simply pass nil wherever you do not want supplementary views to be displayed (leftmost, rightmost, topmost and bottommost).

Reload Layout:

//On Layout:
layout.resetLayoutCache()
//Helper Method for collection view
collectionView.reloadDataAndSpreadsheetLayout()

So in short:

  1. Register the respective objects of type UISupplementaryView you want to use with the provided identifiers of the enum ViewKindType.
  2. Create a UINib object for each UIDecrationView (corner of the Spreadsheet) and pass it upon initialization of the layout.
  3. Initialize the layout with the provided convenience initializer and pass the delegate as well as the required decoration views.
  4. Implement the SpreadsheetLayoutDelegate.
  5. Set the content of your cells and the supplementary views in the data source methods of your collection view.
  6. Enjoy ;)

Questions

Please refer to the demo application or contact me directly.

Author

Wojtek Kordylewski.

indiControl GmbH owns the Copyright of the respective SwiftSpreadsheet.swift file.

License

SwiftSpreadsheet is available under the MIT license. See the LICENSE file for more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.