Skip to content
2 changes: 1 addition & 1 deletion APParallaxHeader.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Pod::Spec.new do |s|
s.summary = 'Add a parallax header view to your table views with one row of code.'
s.homepage = 'https://github.com/apping/APParallaxHeader'
s.author = { 'Mathias Amnell' => '[email protected]' }
s.source = { :git => 'https://github.com/apping/APParallaxHeader.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/djbe/APParallaxHeader.git', :tag => s.version.to_s }

s.description = 'This category makes it super easy to add a parallax header view to your table views. Other alternatives relies on subclassing of UITableViewController or UITableView. Instead, APParallaxHeader uses the Objective-C runtime to add the functionality to your UIScrollView or UITableView.'

Expand Down
2 changes: 2 additions & 0 deletions APParallaxHeader/UIScrollView+APParallaxHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ typedef NS_ENUM(NSUInteger, APParallaxTrackingState) {

@interface APParallaxView : UIView

- (id)initWithFrame:(CGRect)frame andShadow:(BOOL)shadow;

@property (weak) id<APParallaxViewDelegate> delegate;

@property (nonatomic, readonly) APParallaxTrackingState state;
Expand Down
10 changes: 5 additions & 5 deletions APParallaxHeader/UIScrollView+APParallaxHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,19 @@ - (id)initWithFrame:(CGRect)frame andShadow:(BOOL)shadow {
if(self = [super initWithFrame:frame]) {

// default styling values
[self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
[self setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[self setState:APParallaxTrackingActive];
[self setAutoresizesSubviews:YES];

self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame))];
[self.imageView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
[self.imageView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[self.imageView setContentMode:UIViewContentModeScaleAspectFill];
[self.imageView setClipsToBounds:YES];
[self addSubview:self.imageView];

if (shadow) {
self.shadowView = [[APParallaxShadowView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(frame)-8, CGRectGetWidth(frame), 8)];
[self.shadowView setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin];
[self.shadowView setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleWidth];
[self addSubview:self.shadowView];
}
}
Expand Down Expand Up @@ -239,15 +239,15 @@ - (void)scrollViewDidScroll:(CGPoint)contentOffset {
} else {
[self setState:APParallaxTrackingActive];
}

if(self.state == APParallaxTrackingActive) {
CGFloat yOffset = contentOffset.y*-1;
if ([self.delegate respondsToSelector:@selector(parallaxView:willChangeFrame:)]) {
[self.delegate parallaxView:self willChangeFrame:self.frame];
}

[self setFrame:CGRectMake(0, contentOffset.y, CGRectGetWidth(self.frame), yOffset)];

if ([self.delegate respondsToSelector:@selector(parallaxView:didChangeFrame:)]) {
[self.delegate parallaxView:self didChangeFrame:self.frame];
}
Expand Down