pap

PaperKit

PaperKit is like Paper app of Facebook

Showing:

Popularity

Downloads/wk

0

GitHub Stars

157

Maintenance

Last Commit

4yrs ago

Contributors

2

Package

Dependencies

1

License

BSD

Categories

Readme

PaperKit

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

Version Platform License

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100