From c11b90dbebf879059ed97b24a04fa6e085c4c6c8 Mon Sep 17 00:00:00 2001 From: Genady Okrain Date: Sat, 12 Apr 2014 12:34:00 +0300 Subject: [PATCH 1/2] 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 2/2] 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 {