TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2015 |
Maintained by Brandon Shelley.
This category makes it super easy to add a parallax header view to your scroll views. Other alternatives relies on subclassing of UIScrollView
, UITableViewController
or UITableView
. Instead APParallaxHeader uses the Objective-C runtime to add the two following methods to UIScrollView
without the need to do any subclassing.
- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height andShadow:(BOOL)shadow;
- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height;
- (void)addParallaxWithView:(UIView*)view andHeight:(CGFloat)height;
Important note if your project doesn't use ARC: you must add the -fobjc-arc
compiler flag to UIScrollView+ APParallaxHeader.m
in Target Settings > Build Phases > Compile Sources.
APParallaxHeader/APParallaxHeader
folder into your project.UIScrollView+APParallaxHeader.h
wherever you feel the need.(see sample Xcode project in /Demo
)
[tableView addParallaxWithImage:[UIImage imageNamed:@"ImageName"] andHeight:160];
Note: When adding a custom view. Either use APParallaxViewDelegate
, auto layout constraints or contentMode
to resize your custom view during scrolling.
UIView *customView = [[UIView alloc] init];
[customView setFrame:CGRectMake(0, 0, 320, 160)];
[self.tableView addParallaxWithView:customView andHeight:160];
[self.tableView.parallaxView setDelegate:self];
APParallaxViewDelegate will notify the delegate about resizing of the parallax view.
- (void)parallaxView:(APParallaxView *)view willChangeFrame:(CGRect)frame
- (void)parallaxView:(APParallaxView *)view didChangeFrame:(CGRect)frame
UITableViewStylePlain
will not be pinned as expected during scrolling.0.1.6
0.1.5
APParallaxViewDelegate
).0.1.4
0.1.3
0.1.2
APParallaxHeader is brought to you by Mathias Amnell at Apping AB. The code is inspired by Sam Vermette's work with SVPullToRefresh (especially the usage of objc/runtime.h
to make it so easy to implement, without the need of subclassing).
APParallaxHeader is available under the MIT license. See the LICENSE file for more info.