GithubHelp home page GithubHelp logo

yolpsoftware / m6parallaxcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peterpaulis/m6parallaxcontroller

0.0 2.0 0.0 269 KB

Parallax controller for a parallaxed view and a table view

License: Apache License 2.0

m6parallaxcontroller's Introduction

M6ParallaxController

Parallax controller for a parallaxed view and a table view

##Storyboard Usage

  • Add M6ParallaxTableViewController.h / .m and UIViewController+M6ParallaxController.h / .m to your project
  • Create a new ViewController, which subclasses M6ParallaxController
#import <UIKit/UIKit.h>
#import "M6ParallaxController.h"
            
@interface MyParallaxController : M6ParallaxController
            
@end
  • In storyboard, create a view controller and set its class to MyParallaxController
  • Add a UIViewController, which will be parallaxed. Set its Storyboard ID to let's say "ParallaxedViewController"
  • Add a UITableViewController, and create a custom class for it, lets say MyTableViewController (which subclasses the UITableViewController). Inside your implementation of MyTableViewController add :
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    [self.parallaxController tableViewControllerDidScroll:self];
    
}
  • Assign a StoryboardID to your MyTableViewController, let's say "MyTableViewController"
  • In my MyParallaxController add
-(void) awakeFromNib
{
    UIViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ParallaxedViewController"];
    UITableViewController * tvc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyTableViewController"];
    
    [self setupWithViewController:vc height:100 tableViewController:tvc];
}

##Optional Usage

  • you can create a class for your parallaxed UIViewController and make it conform to the delegate method
@interface MyParallaxedViewController : UIViewController<M6ParallaxMasterViewControllerDelegate>
  • and than in MyParallaxController, assign it as delegate
-(void) awakeFromNib
{
    MyParallaxedViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ParallaxedViewController"];
    UITableViewController * tvc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyTableViewController"];
    
    [self setupWithViewController:vc height:100 tableViewController:tvc];
    
    self.delegate = vc;
}
  • and do some custom stuff, like change the Alpha (as in the sample)
- (void)parallaxController:(M6ParallaxController *)parallaxController willChangeHeightOfViewController:(UIViewController *)viewController fromHeight:(CGFloat)oldHeight toHeight:(CGFloat)newHeight {

    if (newHeight >= parallaxController.parallaxedViewControllerStandartHeight) {
    
        [self.imageView setAlpha:1];
        [self.label1 setAlpha:1];
        [self.label2 setAlpha:1];
        [self.label3 setAlpha:1];
        
    } else {
    
        float r = newHeight / parallaxController.parallaxedViewControllerStandartHeight;
        [self.imageView setAlpha:r];
        [self.label1 setAlpha:r];
        [self.label2 setAlpha:r*r];
        [self.label3 setAlpha:r*r*r*r];
        
    }

}

##License Apache License 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt

##Credits min:60 - Building perfect mobile apps, for affordable price - https://min60.com

m6parallaxcontroller's People

Contributors

peterpaulis avatar

Watchers

 avatar  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.