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..142a684 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:YES]; +} + +- (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;