cocoa-chen / PWParallaxScrollView

PWParallaxScrollView is a library that provides a simple way to implement sliding menu of WWF-like style

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PWParallaxScrollView

PWParallaxScrollView is a library that provide a simple way to implement sliding menu of WWF-like style

##CocoaPods

pod "PWParallaxScrollView"

##Usage

#####import header

#import "PWParallaxScrollView.h"

#####follow PWParallaxScrollViewDataSource protocol

@interface ViewController <PWParallaxScrollViewDataSource>

#####implement PWParallaxScrollViewDataSource methods

- (NSInteger)numberOfItemsInScrollView:(PWParallaxScrollView *)scrollView;
- (UIView *)backgroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;
- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;

#####setting ForegroundScreenEdgeInsets

##About ForegroundScreenEdgeInsets ###custom your parallax offset

foregroundScreenEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 100);

#####sample code

    self.scrollView = [[PWParallaxScrollView alloc] initWithFrame:self.view.bounds];
    _scrollView.foregroundScreenEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 100);
    [self.view insertSubview:_scrollView atIndex:0];
    
- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 300, 70)];

	...
	    
    return label;
}

###Normal

foregroundScreenEdgeInsets = UIEdgeInsetsZero;

#####sample code

    self.scrollView = [[PWParallaxScrollView alloc] initWithFrame:self.view.bounds];
    _scrollView.foregroundScreenEdgeInsets = UIEdgeInsetsZero;
    [self.view insertSubview:_scrollView atIndex:0];
    
- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 300, 70)];

	...
	    
    return label;
}

##hit test

- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 300, 70)];
	...
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
	...
    [button addTarget:self action:@selector(test) forControlEvents:UIControlEventTouchUpInside];
    ...
    [label addSubview:button];
    
    return label;
}

##moveToIndex , prev , next

#####sample code

    [scrollView moveToIndex:3];
    [scrollView prevItem];
    [scrollView nextItem];

##background view only

#####just not implement the foregroundViewAtIndex:scrollView: method (or return nil)

- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;


MIT License

see license file

About

PWParallaxScrollView is a library that provides a simple way to implement sliding menu of WWF-like style

License:MIT License