Giter Club home page Giter Club logo

tabbedcollectionview's Introduction

TabbedCollectionView Carthage compatible GitHub release

This is a combination of a UICollectionView and a tabbed controller. Users can use the tabs to switch among categories and the subsets are displayed in the UICollectionView.

CalculatorKeyboard Screenshot

Usage

To run the example project, clone the repo, and open the 'Example/Example.xcodeproj' file.

Requirements

This component is written using Swift and Dynamic Frameworks, so iOS 8.x is required. However you may want to manually import the source files into your project, if you need to support 7.x.

Installation

RFCalculatorKeyboard is available through Carthage. To install it, simply add the following line to your Cartfile:

github "sprint84/TabbedCollectionView" ~> 1.0

###Installing Carthage

To install the carthage tool on your system, please download and run the Carthage.pkg file for the latest release, then follow the on-screen instructions.

Alternately, you can use Homebrew and install the carthage tool on your system simply by running brew update and brew install carthage.

For further details, please visit the Carthage Github page

##Usage

Using TabbedCollectionView is quite simple. First you need to import the Framework

import TabbedCollectionView

You can either create a UIView in a Storyboard and change its class to TabbedCollectionView or instantiate the view in code.

let tabbed = TabbedCollectionView()
self.view.addSubview(tabbed)

In order to create the tabs, you must call the method createTabs(titles:images:) where you can send an array of String and an array of UIImage. The two arrays must be equal size. If one array is larger than the other, the smaller size will be considered.

let titles = ["Home", "Shopping"]
let images = [UIImage(named: "home_icon")!, UIImage(named: "cart_icon")!]
tabbed.createTabs(titles, images: images)

The items in the collection view are populated throught the implementation of the data source methods, similarly to a normal UICollectionView.

func collectionView(collectionView: TabbedCollectionView, numberOfItemsInTab tab: Int) -> Int
func collectionView(collectionView: TabbedCollectionView, titleForItemAtIndexPath indexPath: NSIndexPath) -> String
func collectionView(collectionView: TabbedCollectionView, imageForItemAtIndexPath indexPath: NSIndexPath) -> UIImage
func collectionView(collectionView: TabbedCollectionView, colorForItemAtIndexPath indexPath: NSIndexPath) -> UIColor
func collectionView(collectionView: TabbedCollectionView, titleColorForItemAtIndexPath indexPath: NSIndexPath) -> UIColor
func collectionView(collectionView: TabbedCollectionView, backgroundColorForItemAtIndexPath indexPath: NSIndexPath) -> UIColor

The only catch here is that the method colorForItemAtIndexPath relies on the tintColor to work, so you must use your UIImage with the rendering mode set to .Template.

You must also implement the delegate protocol in order to hear back from selection actions:

func collectionView(collectionView: TabbedCollectionView, didSelectItemAtIndex index: Int, forTab tab: Int)

Customization

TabbedCollectionView supports some customization through the methods:

selectionColor: UIColor
tabTitleColor: UIColor
tabBackgroundColor: UIColor

Author

Reefactor, Inc., [email protected]

License

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

tabbedcollectionview's People

Contributors

sprint84 avatar

Watchers

James Cloos avatar Carabineiro avatar

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.