Skip to content

jkrumow/TBFacetTableView

Repository files navigation

TBFacetTableView

Version License Platform

A UITableView with cells shaped like facets.

Screenshot facets

Screenshot facets highlihgted

Example project

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

Requirements

  • Xcode 5
  • iOS 5.0

Installation

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

pod "TBFacetTableView"

Usage

This pod consists of three classes:

  • TBFacetTableViewCell - UITableViewCell shaped like a facet or shard
  • TBFacetTableViewCellConfigurator - configures the cells
  • TBFacetTableViewCellObserver - handles the highlight state of the cells

To use the classes in your code just import TBFacetTableViewCellConfigurator.h.

Configuring cells

Implement the TBFacetTableViewCellConfiguratorDataSource protocol. The best place is your UIViewController subclass or UITableViewDatasource implementation:

- (UIColor *)facetTableViewCellConfigurator:(TBFacetTableViewCellConfigurator *)facetTableViewCellConfigurator facetColorForCellAtIndexPath:(NSIndexPath *)indexPath
{
    return // whatever color you like
}

- (UIColor *)facetTableViewCellConfigurator:(TBFacetTableViewCellConfigurator *)facetTableViewCellConfigurator highlightColorForCellAtIndexPath:(NSIndexPath *)indexPath;
{
    return // whatever color you like
}

- (CGPathRef)facetTableViewCellConfigurator:(TBFacetTableViewCellConfigurator *)facetTableViewCellConfigurator topPathForCellAtIndexPath:(NSIndexPath *)indexPath
{
    return // whatever CGPathRef you like - should match bottom path of cell above
}

- (CGPathRef)facetTableViewCellConfigurator:(TBFacetTableViewCellConfigurator *)facetTableViewCellConfigurator bottomPathForCellAtIndexPath:(NSIndexPath *)indexPath
{
    return // whatever CGPathRef you like - should match top path of cell below
}

Create an instance of TBFacetTableViewCellConfigurator passing a regular UITableView instance or subtype:

_facetCellConfigurator = [[TBFacetTableViewCellConfigurator alloc] initWithTableView:_facetTableView
                                                                            dataSource:self];

Configuring cells

Configure your TBFacetTableViewCell by passing it and its index path:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    TBFacetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[TBFacetTableViewCell reuseIdentifier]
                                                                 forIndexPath:indexPath];
    [_facetCellConfigurator configureCell:cell atIndexpath:indexPath];
        
    return cell;
}

Author

Julian Krumow, julian.krumow@bogusmachine.com

License

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

About

A UITableView with cells shaped like facets.

Resources

License

Stars

Watchers

Forks

Packages

No packages published