PWParallaxScrollView is a library for creating sliding menus with parallax effect inspired by the WWF app
for ObjC
pod 'PWParallaxScrollView', '~> 1.2.0'
for Swift,
pod 'PWParallaxScrollView/Swift', '~> 1.2.0'
#import "PWParallaxScrollView.h"
@interface ViewController <PWParallaxScrollViewDataSource>
- (NSInteger)numberOfItemsInScrollView:(PWParallaxScrollView *)scrollView;
- (UIView *)backgroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;
- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;
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;
}
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;
}
- (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;
}
[scrollView moveToIndex:3];
[scrollView prevItem];
[scrollView nextItem];
- (UIView *)foregroundViewAtIndex:(NSInteger)index scrollView:(PWParallaxScrollView *)scrollView;
- add swift version
- @yume190
add delegate to receive touchScrollViewTapped event
- (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didRecieveTapAtIndex:(NSInteger)index;
- @Morgan-Kennedy
-
add interface builder support (initWithCoder, Outlets)
-
add PWParallaxDelegate and provides methods to check whether the current index is changed
- @matibot
PWParallaxScrollView is released under the MIT License (see the License file)
Any suggestions or improvements?
feel free to contact me