From 273b0a378b5b5aeecd7fa5d1cd48562670572eb2 Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Mon, 11 Sep 2017 15:40:11 +0200 Subject: [PATCH] - fix width cover --- PNTwitterCover.podspec | 2 +- PNTwitterCover/Classes/PNTwitterCoverView.m | 10 ++++++---- PNTwitterCover/Classes/UIScrollView+PNTwitterCover.h | 1 + PNTwitterCover/Classes/UIScrollView+PNTwitterCover.m | 4 ++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/PNTwitterCover.podspec b/PNTwitterCover.podspec index fad41fa..82e2e9b 100644 --- a/PNTwitterCover.podspec +++ b/PNTwitterCover.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'PNTwitterCover' - s.version = '1.0.1' + s.version = '1.0.2' s.summary = 'PNTwitterCover is a UUIscrollView Category to add blur and zoom during scroll bounce' # This description is used to generate tags and improve search results. diff --git a/PNTwitterCover/Classes/PNTwitterCoverView.m b/PNTwitterCover/Classes/PNTwitterCoverView.m index e2e1b7d..a39932c 100644 --- a/PNTwitterCover/Classes/PNTwitterCoverView.m +++ b/PNTwitterCover/Classes/PNTwitterCoverView.m @@ -13,6 +13,7 @@ @property (nonatomic, strong) NSMutableArray *blurImages; @property (nonatomic, strong) UIView *topView; @property (nonatomic) CGFloat height; +@property (nonatomic) CGFloat width; @end @@ -32,6 +33,7 @@ _blurImages = [[NSMutableArray alloc] initWithCapacity:20]; _topView = view; _height = frame.size.height; + _width = frame.size.width; } return self; } @@ -75,9 +77,9 @@ if (self.scrollView.contentOffset.y < 0) { CGFloat offset = -self.scrollView.contentOffset.y; - _topView.frame = CGRectMake(0, -offset, 320, _topView.bounds.size.height); + _topView.frame = CGRectMake(0, -offset, _width, _topView.bounds.size.height); - self.frame = CGRectMake(-offset,-offset + _topView.bounds.size.height, 320+ offset * 2, _height + offset); + self.frame = CGRectMake(-offset,-offset + _topView.bounds.size.height, _width+ offset * 2, _height + offset); NSInteger index = offset / 10; if (index < 0) { index = 0; @@ -92,9 +94,9 @@ } else { - _topView.frame = CGRectMake(0, 0, 320, _topView.bounds.size.height); + _topView.frame = CGRectMake(0, 0, _width, _topView.bounds.size.height); - self.frame = CGRectMake(0,_topView.bounds.size.height, 320, _height); + self.frame = CGRectMake(0,_topView.bounds.size.height, _width, _height); UIImage *image = _blurImages[0]; if (self.image != image) { diff --git a/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.h b/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.h index 4b9687f..f201ff1 100644 --- a/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.h +++ b/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.h @@ -16,6 +16,7 @@ - (void)addTwitterCoverWithImage:(UIImage*)image; - (void)addTwitterCoverWithImage:(UIImage*)image withTopView:(UIView*)topView; +- (void)addTwitterCoverWithImage:(UIImage*)image withTopView:(UIView*)topView andHeight:(CGFloat) height; - (void)addTwitterCoverWithImage:(UIImage*)image withTopView:(UIView*)topView width:(CGFloat) width andHeight:(CGFloat) height; - (void)removeTwitterCoverView; diff --git a/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.m b/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.m index 2ee9ff5..f2c90f2 100644 --- a/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.m +++ b/PNTwitterCover/Classes/UIScrollView+PNTwitterCover.m @@ -34,6 +34,10 @@ static char UIScrollViewTwitterCover; [self addTwitterCoverWithImage:image withTopView:topView width:[UIScreen mainScreen].bounds.size.width andHeight:DefaultTwitterCoverViewHeight]; } +- (void)addTwitterCoverWithImage:(UIImage*)image withTopView:(UIView*)topView andHeight:(CGFloat) height { + [self addTwitterCoverWithImage:image withTopView:topView width:[UIScreen mainScreen].bounds.size.width andHeight:height]; +} + - (void)addTwitterCoverWithImage:(UIImage*)image withTopView:(UIView*)topView width:(CGFloat) width andHeight:(CGFloat) height { PNTwitterCoverView *view = [[PNTwitterCoverView alloc] initWithFrame:CGRectMake(0,0, width, height) andContentTopView:topView];