From 57efa7fd8ebaba4d62691c04ddcc99f77a97380d Mon Sep 17 00:00:00 2001 From: David Jennes Date: Sat, 30 Nov 2013 23:56:27 +0100 Subject: [PATCH 1/8] fix header size in landscape mode --- APParallaxHeader/UIScrollView+APParallaxHeader.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.m b/APParallaxHeader/UIScrollView+APParallaxHeader.m index 1ae089b..da41d3d 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.m +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.m @@ -171,12 +171,12 @@ - (id)initWithFrame:(CGRect)frame { 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]; From c11b90dbebf879059ed97b24a04fa6e085c4c6c8 Mon Sep 17 00:00:00 2001 From: Genady Okrain Date: Sat, 12 Apr 2014 12:34:00 +0300 Subject: [PATCH 2/8] option to init without shadow --- APParallaxHeader/UIScrollView+APParallaxHeader.h | 3 +++ APParallaxHeader/UIScrollView+APParallaxHeader.m | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.h b/APParallaxHeader/UIScrollView+APParallaxHeader.h index dd374de..fff5a73 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.h +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.h @@ -12,6 +12,7 @@ @interface UIScrollView (APParallaxHeader) +- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height andShadow:(BOOL)shadow; - (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height; - (void)addParallaxWithView:(UIView*)view andHeight:(CGFloat)height; @@ -29,6 +30,8 @@ typedef NSUInteger APParallaxTrackingState; @interface APParallaxView : UIView +- (id)initWithFrame:(CGRect)frame andShadow:(BOOL)shadow; + @property (nonatomic, readonly) APParallaxTrackingState state; @property (nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UIView *currentSubView; diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.m b/APParallaxHeader/UIScrollView+APParallaxHeader.m index 1ae089b..e6ef422 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.m +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.m @@ -31,13 +31,17 @@ @interface APParallaxView () @implementation UIScrollView (APParallaxHeader) - (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height { + [self addParallaxWithImage:image andHeight:height andShadow:NO]; +} + +- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height andShadow:(BOOL)shadow { if(self.parallaxView) { if(self.parallaxView.currentSubView) [self.parallaxView.currentSubView removeFromSuperview]; [self.parallaxView.imageView setImage:image]; } else { - APParallaxView *view = [[APParallaxView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, height)]; + APParallaxView *view = [[APParallaxView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, height) andShadow:shadow]; [view setClipsToBounds:YES]; [view.imageView setImage:image]; @@ -167,7 +171,7 @@ - (void)drawRect:(CGRect)rect @implementation APParallaxView -- (id)initWithFrame:(CGRect)frame { +- (id)initWithFrame:(CGRect)frame andShadow:(BOOL)shadow { if(self = [super initWithFrame:frame]) { // default styling values @@ -181,9 +185,11 @@ - (id)initWithFrame:(CGRect)frame { [self.imageView setClipsToBounds:YES]; [self addSubview:self.imageView]; - self.shadowView = [[APParallaxShadowView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(frame)-8, CGRectGetWidth(frame), 8)]; - [self.shadowView setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin]; - [self addSubview:self.shadowView]; + if (shadow) { + self.shadowView = [[APParallaxShadowView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(frame)-8, CGRectGetWidth(frame), 8)]; + [self.shadowView setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin]; + [self addSubview:self.shadowView]; + } } return self; From 473a3c50daa6e05b533cf2a1a72df6dc0412f749 Mon Sep 17 00:00:00 2001 From: Genady Okrain Date: Sat, 12 Apr 2014 12:39:53 +0300 Subject: [PATCH 3/8] default shadow is yes --- APParallaxHeader/UIScrollView+APParallaxHeader.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.m b/APParallaxHeader/UIScrollView+APParallaxHeader.m index e6ef422..142a684 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.m +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.m @@ -31,7 +31,7 @@ @interface APParallaxView () @implementation UIScrollView (APParallaxHeader) - (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height { - [self addParallaxWithImage:image andHeight:height andShadow:NO]; + [self addParallaxWithImage:image andHeight:height andShadow:YES]; } - (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height andShadow:(BOOL)shadow { From 64389ac8321b1a1a7720add1d53647b169ced430 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Wed, 4 Jun 2014 18:31:07 +0200 Subject: [PATCH 4/8] merge fix from @timominous --- APParallaxHeader/UIScrollView+APParallaxHeader.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.m b/APParallaxHeader/UIScrollView+APParallaxHeader.m index da41d3d..0a71bd1 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.m +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.m @@ -225,11 +225,22 @@ - (void)scrollViewDidScroll:(CGPoint)contentOffset { } else { [self setState:APParallaxTrackingActive]; } - + + UIEdgeInsets insets = self.scrollView.contentInset; + if(self.state == APParallaxTrackingActive) { CGFloat yOffset = contentOffset.y*-1; [self setFrame:CGRectMake(0, contentOffset.y, CGRectGetWidth(self.frame), yOffset)]; - } + + if (yOffset > self.parallaxHeight) + insets.top = self.parallaxHeight; + else + insets.top = yOffset; + } else { + insets.top = 0; + } + + self.scrollView.contentInset = insets; } @end From d4c984c2643a2dc123c81f592bb97a134251d802 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Wed, 4 Jun 2014 18:35:47 +0200 Subject: [PATCH 5/8] update pod spec url to point to our own repo --- APParallaxHeader.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APParallaxHeader.podspec b/APParallaxHeader.podspec index 9a4bf64..0404122 100644 --- a/APParallaxHeader.podspec +++ b/APParallaxHeader.podspec @@ -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' => 'mathias@apping.se' } - 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. APParallaxHeader uses the Objective-C runtime instead to add the following method to UIScrollView.' From f1e1fd37c82af71750486d4cb886c500f7e80aad Mon Sep 17 00:00:00 2001 From: David Jennes Date: Fri, 18 Jul 2014 17:04:54 +0200 Subject: [PATCH 6/8] fix merge error --- APParallaxHeader/UIScrollView+APParallaxHeader.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.h b/APParallaxHeader/UIScrollView+APParallaxHeader.h index a810a47..1105af3 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.h +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.h @@ -34,6 +34,8 @@ typedef NS_ENUM(NSUInteger, APParallaxTrackingState) { @interface APParallaxView : UIView +- (id)initWithFrame:(CGRect)frame andShadow:(BOOL)shadow; + @property (weak) id delegate; @property (nonatomic, readonly) APParallaxTrackingState state; From 8218d93e3423fa959d9d4d6ceea775adc56bb180 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Mon, 28 Jul 2014 15:04:23 +0200 Subject: [PATCH 7/8] fix rotation shadow issue --- APParallaxHeader/UIScrollView+APParallaxHeader.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.m b/APParallaxHeader/UIScrollView+APParallaxHeader.m index a140169..116b430 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.m +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.m @@ -196,7 +196,7 @@ - (id)initWithFrame:(CGRect)frame andShadow:(BOOL)shadow { 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]; } } From c7edd6a83033ab0e948c2087d9d076baaa4c9284 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Fri, 1 Aug 2014 14:03:20 +0200 Subject: [PATCH 8/8] don't modify content insets on scroll, breaks inertia scrolling! --- APParallaxHeader/UIScrollView+APParallaxHeader.m | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/APParallaxHeader/UIScrollView+APParallaxHeader.m b/APParallaxHeader/UIScrollView+APParallaxHeader.m index 116b430..921d5a4 100755 --- a/APParallaxHeader/UIScrollView+APParallaxHeader.m +++ b/APParallaxHeader/UIScrollView+APParallaxHeader.m @@ -240,8 +240,6 @@ - (void)scrollViewDidScroll:(CGPoint)contentOffset { [self setState:APParallaxTrackingActive]; } - UIEdgeInsets insets = self.scrollView.contentInset; - if(self.state == APParallaxTrackingActive) { CGFloat yOffset = contentOffset.y*-1; if ([self.delegate respondsToSelector:@selector(parallaxView:willChangeFrame:)]) { @@ -253,16 +251,7 @@ - (void)scrollViewDidScroll:(CGPoint)contentOffset { if ([self.delegate respondsToSelector:@selector(parallaxView:didChangeFrame:)]) { [self.delegate parallaxView:self didChangeFrame:self.frame]; } - - if (yOffset > self.parallaxHeight) - insets.top = self.parallaxHeight; - else - insets.top = yOffset; - } else { - insets.top = 0; - } - - self.scrollView.contentInset = insets; + } } @end