PaperKit 0.8.1

PaperKit 0.8.1

TestsTested
LangLanguage Obj-CObjective C
License BSD
ReleasedLast Release Apr 2016

Maintained by 1amageek.




PaperKit 0.8.1

PaperKit is Framework that can easily create a Facebook's Paper.It can be created to operate the CollectionView of UIKit.

sample

Try Sample

requirement : Xcode7 beta4

$ pod try PaperKit

Alternatively, appetize.io

Quick start

PaperKit is available on CocoaPods. Add the following to your Podfile:

pod 'PaperKit'

Import the framework header, or create an Objective-C bridging header if you're using Swift:

#import <PaperKit/PaperKit.h>

Inherit the PKViewController

@interface ViewController : PKViewController

Usage

PKViewController

The PKViewController there are multiple CollectionView. To control the respective CollectionViewController, override the following method.

- (NSInteger)backgroundCollectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    // override method
    return 10;
}

- (NSInteger)foregroundCollectionVew:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section onCategory:(NSInteger)category
{
    // override method
    return 10;
}
- (UICollectionViewCell *)backgroundCollectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    CGFloat color = floorf(indexPath.item)/[self backgroundCollectionView:collectionView numberOfItemsInSection:indexPath.section];
    cell.backgroundColor = [UIColor colorWithHue:color saturation:1 brightness:1 alpha:1];
    return cell;
}

- (PKContentViewController *)foregroundCollectionView:(PKCollectionView *)collectionView contentViewControllerForAtIndexPath:(NSIndexPath *)indexPath onCategory:(NSUInteger)category
{
    NSLog(@"indexPaht %@ cateogry %lu",indexPath, (unsigned long)category);
    return [ContentViewController new];
}

You can use the method for Datasource reload. This method is called when you pull beyond the contentSize of scroll view.

- (void)scrollView:(UIScrollView *)scrollView slideToAction:(PKCollectionViewControllerScrollDirection)direction;
{
    if (direction == PKCollectionViewControllerScrollDirectionPrevious) {
        NSLog(@"PKCollectionViewControllerScrollDirectionPrevious");
    } else {
        NSLog(@"PKCollectionViewControllerScrollDirectionNext");
    }
}

To reload the datasource, run the following method.

// backgroundCollectionView dataSource reload
[self reloadBackgroundData];

// foregroundCollectionView dataSource reload
[self reloadForegroundDataOnCategory:self.selectedCategory];

PKWindow

PKWindow can be hierarchically arranged the Window. PKWindow is managed by PKWindowManager.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    BackgroundViewController *backgroundViewController = [BackgroundViewController new];
    self.window.rootViewController = backgroundViewController;
    [self.window makeKeyAndVisible];

    [PKWindowManager managerWithBaseWindow:self.window];

    return YES;
}

Create a new Window by passing the RootViewController to PKWindowManger.

ViewController *nextViewController = [ViewController new];
[[PKWindowManager sharedManager] showWindowWithRootViewController:nextViewController];

Learn more