From d4a9c93e461419f19fac2cbbd5837a96ab79f012 Mon Sep 17 00:00:00 2001 From: pastorin Date: Fri, 31 Jul 2015 17:06:53 -0300 Subject: [PATCH 1/2] issue #4 - Change the look and feel of a XLButtonBarViewCell based on the selected state --- README.md | 11 +++++ XLPagerTabStrip/Demo/ButtonCell.xib | 13 +++--- .../Demo/NavButtonBarExampleViewController.m | 21 ++++++++++ XLPagerTabStrip/Demo/Storyboard.storyboard | 4 +- .../XLBarPagerTabStripViewController.m | 1 + .../XLButtonBarPagerTabStripViewController.h | 4 ++ .../XLButtonBarPagerTabStripViewController.m | 40 ++++++++++++++++++- .../XLPagerTabStripViewController.h | 3 +- .../XLPagerTabStripViewController.m | 6 ++- .../XLSegmentedPagerTabStripViewController.m | 1 + .../XLTwitterPagerTabStripViewController.m | 1 + 11 files changed, 92 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8e883e2..75c1c04 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,17 @@ FAQ -(void)moveToViewController:(UIViewController *)viewController; ``` +#####How to change the look and feel of a XLButtonBarViewCell based on the selected state + +`XLButtonBarPagerTabStripViewController` provides a flexible way to customize the look and feel of a `XLButtonBarViewCell` based on the selected state by using blocks. These blocks will be called each time the current cell index changes its value. +Not only can you change the text color, but also the font, size, background color and so on. + +```objc +@property (copy) void (^changeCurrentIndexProgressiveBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, CGFloat progressPercentage, BOOL changeCurrentIndex, BOOL fromCellRowAtIndex); +@property (copy) void (^changeCurrentIndexBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, BOOL animated); +``` + + Installation -------------------------- diff --git a/XLPagerTabStrip/Demo/ButtonCell.xib b/XLPagerTabStrip/Demo/ButtonCell.xib index b20e7d1..aa52b90 100644 --- a/XLPagerTabStrip/Demo/ButtonCell.xib +++ b/XLPagerTabStrip/Demo/ButtonCell.xib @@ -1,21 +1,20 @@ - + - + - + - diff --git a/XLPagerTabStrip/Demo/NavButtonBarExampleViewController.m b/XLPagerTabStrip/Demo/NavButtonBarExampleViewController.m index 7eee413..e24d549 100644 --- a/XLPagerTabStrip/Demo/NavButtonBarExampleViewController.m +++ b/XLPagerTabStrip/Demo/NavButtonBarExampleViewController.m @@ -26,6 +26,7 @@ #import "TableChildExampleViewController.h" #import "ChildExampleViewController.h" #import "NavButtonBarExampleViewController.h" +#import "XLButtonBarViewCell.h" @implementation NavButtonBarExampleViewController { @@ -42,6 +43,26 @@ [self.navigationController.navigationBar addSubview:self.buttonBarView]; [self.buttonBarView registerNib:[UINib nibWithNibName:@"ButtonCell" bundle:[NSBundle bundleForClass:[self class]]] forCellWithReuseIdentifier:@"Cell"]; + + self.changeCurrentIndexProgressiveBlock = ^void(XLButtonBarViewCell *oldCell, XLButtonBarViewCell *newCell, CGFloat progressPercentage, BOOL changeCurrentIndex, BOOL animated){ + if (changeCurrentIndex) { + [oldCell.label setTextColor:[UIColor colorWithWhite:1 alpha:0.6]]; + [newCell.label setTextColor:[UIColor whiteColor]]; + + if (animated) { + [UIView animateWithDuration:0.1 + animations:^(){ + newCell.transform = CGAffineTransformMakeScale(1.0, 1.0); + oldCell.transform = CGAffineTransformMakeScale(0.8, 0.8); + } + completion:nil]; + } + else{ + newCell.transform = CGAffineTransformMakeScale(1.0, 1.0); + oldCell.transform = CGAffineTransformMakeScale(0.8, 0.8); + } + } + }; } #pragma mark - XLPagerTabStripViewControllerDataSource diff --git a/XLPagerTabStrip/Demo/Storyboard.storyboard b/XLPagerTabStrip/Demo/Storyboard.storyboard index cae6028..94c41ad 100644 --- a/XLPagerTabStrip/Demo/Storyboard.storyboard +++ b/XLPagerTabStrip/Demo/Storyboard.storyboard @@ -1,8 +1,8 @@ - + - + diff --git a/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m index 8730822..80b302f 100644 --- a/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m @@ -90,6 +90,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage + andChangeCurrentIndex:(BOOL)changeCurrentIndex { [self.barView moveFromIndex:fromIndex toIndex:toIndex diff --git a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h index c276864..cf95e2c 100644 --- a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h +++ b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h @@ -24,10 +24,14 @@ // THE SOFTWARE. #import "XLButtonBarView.h" +#import "XLButtonBarViewCell.h" #import "XLPagerTabStripViewController.h" @interface XLButtonBarPagerTabStripViewController : XLPagerTabStripViewController +@property (copy) void (^changeCurrentIndexProgressiveBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, CGFloat progressPercentage, BOOL changeCurrentIndex, BOOL fromCellRowAtIndex); +@property (copy) void (^changeCurrentIndexBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, BOOL animated); + @property (readonly, nonatomic) XLButtonBarView * buttonBarView; @end diff --git a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m index 803d7eb..88bfa97 100644 --- a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m @@ -123,6 +123,11 @@ direction = XLPagerTabStripDirectionRight; } [self.buttonBarView moveToIndex:toIndex animated:YES swipeDirection:direction]; + if (self.changeCurrentIndexBlock) { + XLButtonBarViewCell *oldCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex != fromIndex ? fromIndex : toIndex inSection:0]]; + XLButtonBarViewCell *newCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0]]; + self.changeCurrentIndexBlock(oldCell, newCell, YES); + } } } @@ -130,11 +135,18 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage + andChangeCurrentIndex:(BOOL)changeCurrentIndex { if (self.shouldUpdateButtonBarView){ [self.buttonBarView moveFromIndex:fromIndex toIndex:toIndex withProgressPercentage:progressPercentage]; + + if (self.changeCurrentIndexProgressiveBlock) { + XLButtonBarViewCell *oldCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex != fromIndex ? fromIndex : toIndex inSection:0]]; + XLButtonBarViewCell *newCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0]]; + self.changeCurrentIndexProgressiveBlock(oldCell, newCell, progressPercentage, changeCurrentIndex, YES); + } } } @@ -159,7 +171,21 @@ { [self.buttonBarView moveToIndex:indexPath.item animated:YES swipeDirection:XLPagerTabStripDirectionNone]; self.shouldUpdateButtonBarView = NO; - [self moveToViewControllerAtIndex:indexPath.item]; + + XLButtonBarViewCell *oldCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0]]; + XLButtonBarViewCell *newCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:indexPath.item inSection:0]]; + if (self.isProgressiveIndicator) { + if (self.changeCurrentIndexProgressiveBlock) { + self.changeCurrentIndexProgressiveBlock(oldCell, newCell, 1, YES, YES); + } + } + else{ + if (self.changeCurrentIndexBlock) { + self.changeCurrentIndexBlock(oldCell, newCell, YES); + } + } + + [self moveToViewControllerAtIndex:indexPath.item]; } #pragma merk - UICollectionViewDataSource @@ -182,6 +208,18 @@ [buttonBarCell.label setText:[childController titleForPagerTabStripViewController:self]]; + + if (self.isProgressiveIndicator) { + if (self.changeCurrentIndexProgressiveBlock) { + self.changeCurrentIndexProgressiveBlock(self.currentIndex == indexPath.item ? nil : cell , self.currentIndex == indexPath.item ? cell : nil, 1, YES, NO); + } + } + else{ + if (self.changeCurrentIndexBlock) { + self.changeCurrentIndexBlock(self.currentIndex == indexPath.item ? nil : cell , self.currentIndex == indexPath.item ? cell : nil, NO); + } + } + return buttonBarCell; } diff --git a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h index 6162892..dc64374 100644 --- a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h +++ b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h @@ -65,7 +65,8 @@ typedef NS_ENUM(NSUInteger, XLPagerTabStripDirection) { -(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex - withProgressPercentage:(CGFloat)progressPercentage; + withProgressPercentage:(CGFloat)progressPercentage + andChangeCurrentIndex:(BOOL)changeCurrentIndex; @end diff --git a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m index 1dfdbc7..91506ce 100644 --- a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m @@ -186,6 +186,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage + andChangeCurrentIndex:(BOOL)changeCurrentIndex { } @@ -325,9 +326,10 @@ NSInteger virtualPage = [self virtualPageForContentOffset:self.containerView.contentOffset.x]; NSUInteger newCurrentIndex = [self pageForVirtualPage:virtualPage]; self.currentIndex = newCurrentIndex; + BOOL changeCurrentIndex = newCurrentIndex != oldCurrentIndex; if (self.isProgressiveIndicator){ - if ([self.delegate respondsToSelector:@selector(pagerTabStripViewController:updateIndicatorFromIndex:toIndex:withProgressPercentage:)]){ + if ([self.delegate respondsToSelector:@selector(pagerTabStripViewController:updateIndicatorFromIndex:toIndex:withProgressPercentage:andChangeCurrentIndex:)]){ CGFloat scrollPercentage = [self scrollPercentage]; if (scrollPercentage > 0) { NSInteger fromIndex = self.currentIndex; @@ -361,7 +363,7 @@ } } } - [self.delegate pagerTabStripViewController:self updateIndicatorFromIndex:fromIndex toIndex:toIndex withProgressPercentage:(self.isElasticIndicatorLimit ? scrollPercentage : ( toIndex < 0 || toIndex >= self.pagerTabStripChildViewControllers.count ? 0 : scrollPercentage ))]; + [self.delegate pagerTabStripViewController:self updateIndicatorFromIndex:fromIndex toIndex:toIndex withProgressPercentage:(self.isElasticIndicatorLimit ? scrollPercentage : ( toIndex < 0 || toIndex >= self.pagerTabStripChildViewControllers.count ? 0 : scrollPercentage )) andChangeCurrentIndex:changeCurrentIndex]; } } } diff --git a/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m index e95ae35..2e54eff 100644 --- a/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m @@ -135,6 +135,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage + andChangeCurrentIndex:(BOOL)changeCurrentIndex { if (self.shouldUpdateSegmentedControl){ NSInteger currentIndex = (progressPercentage > 0.5) ? toIndex : fromIndex; diff --git a/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m index ff9373b..4ab12b6 100644 --- a/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m @@ -142,6 +142,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage + andChangeCurrentIndex:(BOOL)changeCurrentIndex { CGFloat distance = [self getDistanceValue]; UIAccelerationValue xOffset = fromIndex < toIndex ? distance * fromIndex + distance * progressPercentage : distance * fromIndex - distance * progressPercentage; From c90cb52c4c58e053beb6f05571c2e81a955b91a5 Mon Sep 17 00:00:00 2001 From: Martin Barreto Date: Sat, 1 Aug 2015 19:58:24 -0300 Subject: [PATCH 2/2] Added ability to change tab bar style using blocks. --- README.md | 16 +++++++++++----- XLPagerTabStrip.podspec | 4 ++-- XLPagerTabStrip.xcodeproj/project.pbxproj | 10 +++++----- .../XLBarPagerTabStripViewController.m | 2 +- .../XLButtonBarPagerTabStripViewController.h | 2 +- .../XLButtonBarPagerTabStripViewController.m | 11 +++++------ .../Controllers/XLPagerTabStripViewController.h | 2 +- .../Controllers/XLPagerTabStripViewController.m | 6 +++--- .../XLSegmentedPagerTabStripViewController.m | 2 +- .../XLTwitterPagerTabStripViewController.m | 2 +- 10 files changed, 31 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 75c1c04..8e1bde3 100644 --- a/README.md +++ b/README.md @@ -43,16 +43,15 @@ FAQ -(void)moveToViewController:(UIViewController *)viewController; ``` -#####How to change the look and feel of a XLButtonBarViewCell based on the selected state +#####How to change the selected tab (XLButtonBarViewCell) look and feel based on the selected state -`XLButtonBarPagerTabStripViewController` provides a flexible way to customize the look and feel of a `XLButtonBarViewCell` based on the selected state by using blocks. These blocks will be called each time the current cell index changes its value. -Not only can you change the text color, but also the font, size, background color and so on. +`XLButtonBarPagerTabStripViewController` provides a flexible way to customize the look and feel of a `XLButtonBarViewCell` based on the selected state by using blocks. These blocks will be called each time the current cell index changes its value. ```objc -@property (copy) void (^changeCurrentIndexProgressiveBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, CGFloat progressPercentage, BOOL changeCurrentIndex, BOOL fromCellRowAtIndex); +@property (copy) void (^changeCurrentIndexProgressiveBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, CGFloat progressPercentage, BOOL indexWasChanged, BOOL animated); @property (copy) void (^changeCurrentIndexBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, BOOL animated); ``` - +Since the collection cell (tab) is passed as a parameter you have full control on the look and fell change and animation. Installation -------------------------- @@ -86,6 +85,13 @@ Requirements Release Notes -------------- +Version 2.0.0 (master) + +* Added ability to change look and feel of selected tab. +* `changeCurrentIndexProgressiveBlock` added to `XLButtonBarPagerTabStripViewController`. +* `changeCurrentIndexBlock` added to `XLButtonBarPagerTabStripViewController`. +* indxWasChanged parameter was added to `-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage indexWasChanged:(BOOL)indexWasChanged;` + Version 1.1.1 * Nav Button example added diff --git a/XLPagerTabStrip.podspec b/XLPagerTabStrip.podspec index 3cdde3e..e3a0eee 100644 --- a/XLPagerTabStrip.podspec +++ b/XLPagerTabStrip.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'XLPagerTabStrip' - s.version = '1.1.1' + s.version = '2.0.0' s.license = 'MIT' s.summary = 'PagerTabStrip for iOS and much more!' s.description = <<-DESC @@ -8,7 +8,7 @@ Pod::Spec.new do |s| DESC s.homepage = 'https://github.com/xmartlabs/XLPagerTabStrip' s.authors = { 'Martin Barreto' => 'martin@xmartlabs.com', 'Washington Miranda' => 'mirandaacevedo@gmail.com' } - s.source = { :git => 'https://github.com/xmartlabs/XLPagerTabStrip.git', :tag => 'v1.1.1' } + s.source = { :git => 'https://github.com/xmartlabs/XLPagerTabStrip.git', :tag => 'v2.0.0' } s.source_files = 'XLPagerTabStrip/XL/**/*.{h,m}' s.requires_arc = true s.ios.deployment_target = '7.0' diff --git a/XLPagerTabStrip.xcodeproj/project.pbxproj b/XLPagerTabStrip.xcodeproj/project.pbxproj index 7635b50..b6f92cb 100644 --- a/XLPagerTabStrip.xcodeproj/project.pbxproj +++ b/XLPagerTabStrip.xcodeproj/project.pbxproj @@ -78,13 +78,13 @@ 28B63AD21A45A4CD00225C66 /* XLButtonBarViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLButtonBarViewCell.h; sourceTree = ""; }; 28B63AD31A45A4CD00225C66 /* XLButtonBarViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLButtonBarViewCell.m; sourceTree = ""; }; 28B63AE71A45B26600225C66 /* XLBarPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLBarPagerTabStripViewController.h; path = Controllers/XLBarPagerTabStripViewController.h; sourceTree = ""; }; - 28B63AE81A45B26600225C66 /* XLBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLBarPagerTabStripViewController.m; path = Controllers/XLBarPagerTabStripViewController.m; sourceTree = ""; }; + 28B63AE81A45B26600225C66 /* XLBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLBarPagerTabStripViewController.m; path = Controllers/XLBarPagerTabStripViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 28B63AE91A45B26600225C66 /* XLButtonBarPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLButtonBarPagerTabStripViewController.h; path = Controllers/XLButtonBarPagerTabStripViewController.h; sourceTree = ""; }; - 28B63AEA1A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLButtonBarPagerTabStripViewController.m; path = Controllers/XLButtonBarPagerTabStripViewController.m; sourceTree = ""; }; + 28B63AEA1A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLButtonBarPagerTabStripViewController.m; path = Controllers/XLButtonBarPagerTabStripViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 28B63AEB1A45B26600225C66 /* XLPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLPagerTabStripViewController.h; path = Controllers/XLPagerTabStripViewController.h; sourceTree = ""; }; - 28B63AEC1A45B26600225C66 /* XLPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLPagerTabStripViewController.m; path = Controllers/XLPagerTabStripViewController.m; sourceTree = ""; }; + 28B63AEC1A45B26600225C66 /* XLPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLPagerTabStripViewController.m; path = Controllers/XLPagerTabStripViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 28B63AED1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLSegmentedPagerTabStripViewController.h; path = Controllers/XLSegmentedPagerTabStripViewController.h; sourceTree = ""; }; - 28B63AEE1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLSegmentedPagerTabStripViewController.m; path = Controllers/XLSegmentedPagerTabStripViewController.m; sourceTree = ""; }; + 28B63AEE1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLSegmentedPagerTabStripViewController.m; path = Controllers/XLSegmentedPagerTabStripViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 28B63AF31A465E5E00225C66 /* ReloadExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReloadExampleViewController.h; sourceTree = ""; }; 28B63AF41A465E5E00225C66 /* ReloadExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReloadExampleViewController.m; sourceTree = ""; }; 28E89E3A1AD74D99004BD9CD /* FXPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FXPageControl.h; path = XLPagerTabStrip/XL/Views/FXPageControl/FXPageControl.h; sourceTree = SOURCE_ROOT; }; @@ -93,7 +93,7 @@ 6624E45A1AEEF9A50076274D /* NavButtonBarExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavButtonBarExampleViewController.h; sourceTree = ""; }; 6624E45B1AEEF9A50076274D /* NavButtonBarExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavButtonBarExampleViewController.m; sourceTree = ""; }; 66CA35B21A8D174900564221 /* XLTwitterPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLTwitterPagerTabStripViewController.h; path = Controllers/XLTwitterPagerTabStripViewController.h; sourceTree = ""; }; - 66CA35B31A8D174900564221 /* XLTwitterPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLTwitterPagerTabStripViewController.m; path = Controllers/XLTwitterPagerTabStripViewController.m; sourceTree = ""; }; + 66CA35B31A8D174900564221 /* XLTwitterPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLTwitterPagerTabStripViewController.m; path = Controllers/XLTwitterPagerTabStripViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; C262204C1AD44A4D002E5226 /* TwitterExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TwitterExampleViewController.h; sourceTree = ""; }; C262204D1AD44A4D002E5226 /* TwitterExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TwitterExampleViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ diff --git a/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m index 80b302f..e7ed55b 100644 --- a/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLBarPagerTabStripViewController.m @@ -90,7 +90,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage - andChangeCurrentIndex:(BOOL)changeCurrentIndex + indexWasChanged:(BOOL)indexWasChanged { [self.barView moveFromIndex:fromIndex toIndex:toIndex diff --git a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h index cf95e2c..834b9e6 100644 --- a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h +++ b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.h @@ -29,7 +29,7 @@ @interface XLButtonBarPagerTabStripViewController : XLPagerTabStripViewController -@property (copy) void (^changeCurrentIndexProgressiveBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, CGFloat progressPercentage, BOOL changeCurrentIndex, BOOL fromCellRowAtIndex); +@property (copy) void (^changeCurrentIndexProgressiveBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, CGFloat progressPercentage, BOOL indexWasChanged, BOOL fromCellRowAtIndex); @property (copy) void (^changeCurrentIndexBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, BOOL animated); @property (readonly, nonatomic) XLButtonBarView * buttonBarView; diff --git a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m index 88bfa97..abbc7d9 100644 --- a/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLButtonBarPagerTabStripViewController.m @@ -88,8 +88,7 @@ -(void)reloadPagerTabStripView { [super reloadPagerTabStripView]; - if ([self isViewLoaded]) - { + if ([self isViewLoaded]){ [self.buttonBarView reloadData]; [self.buttonBarView moveToIndex:self.currentIndex animated:NO swipeDirection:XLPagerTabStripDirectionNone]; } @@ -135,7 +134,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage - andChangeCurrentIndex:(BOOL)changeCurrentIndex + indexWasChanged:(BOOL)indexWasChanged { if (self.shouldUpdateButtonBarView){ [self.buttonBarView moveFromIndex:fromIndex @@ -145,7 +144,7 @@ if (self.changeCurrentIndexProgressiveBlock) { XLButtonBarViewCell *oldCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex != fromIndex ? fromIndex : toIndex inSection:0]]; XLButtonBarViewCell *newCell = (XLButtonBarViewCell*)[self.buttonBarView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0]]; - self.changeCurrentIndexProgressiveBlock(oldCell, newCell, progressPercentage, changeCurrentIndex, YES); + self.changeCurrentIndexProgressiveBlock(oldCell, newCell, progressPercentage, indexWasChanged, YES); } } } @@ -195,10 +194,10 @@ return self.pagerTabStripChildViewControllers.count; } -// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: + - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; + XLButtonBarViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; if (!cell){ cell = [[XLButtonBarViewCell alloc] initWithFrame:CGRectMake(0, 0, 50, self.buttonBarView.frame.size.height)]; } diff --git a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h index dc64374..b76a1ef 100644 --- a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h +++ b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.h @@ -66,7 +66,7 @@ typedef NS_ENUM(NSUInteger, XLPagerTabStripDirection) { updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage - andChangeCurrentIndex:(BOOL)changeCurrentIndex; + indexWasChanged:(BOOL)indexWasChanged; @end diff --git a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m index 91506ce..bf175f3 100644 --- a/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLPagerTabStripViewController.m @@ -186,7 +186,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage - andChangeCurrentIndex:(BOOL)changeCurrentIndex + indexWasChanged:(BOOL)indexWasChanged { } @@ -329,7 +329,7 @@ BOOL changeCurrentIndex = newCurrentIndex != oldCurrentIndex; if (self.isProgressiveIndicator){ - if ([self.delegate respondsToSelector:@selector(pagerTabStripViewController:updateIndicatorFromIndex:toIndex:withProgressPercentage:andChangeCurrentIndex:)]){ + if ([self.delegate respondsToSelector:@selector(pagerTabStripViewController:updateIndicatorFromIndex:toIndex:withProgressPercentage:indexWasChanged:)]){ CGFloat scrollPercentage = [self scrollPercentage]; if (scrollPercentage > 0) { NSInteger fromIndex = self.currentIndex; @@ -363,7 +363,7 @@ } } } - [self.delegate pagerTabStripViewController:self updateIndicatorFromIndex:fromIndex toIndex:toIndex withProgressPercentage:(self.isElasticIndicatorLimit ? scrollPercentage : ( toIndex < 0 || toIndex >= self.pagerTabStripChildViewControllers.count ? 0 : scrollPercentage )) andChangeCurrentIndex:changeCurrentIndex]; + [self.delegate pagerTabStripViewController:self updateIndicatorFromIndex:fromIndex toIndex:toIndex withProgressPercentage:(self.isElasticIndicatorLimit ? scrollPercentage : ( toIndex < 0 || toIndex >= self.pagerTabStripChildViewControllers.count ? 0 : scrollPercentage )) indexWasChanged:changeCurrentIndex]; } } } diff --git a/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m index 2e54eff..369f424 100644 --- a/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLSegmentedPagerTabStripViewController.m @@ -135,7 +135,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage - andChangeCurrentIndex:(BOOL)changeCurrentIndex + indexWasChanged:(BOOL)indexWasChanged { if (self.shouldUpdateSegmentedControl){ NSInteger currentIndex = (progressPercentage > 0.5) ? toIndex : fromIndex; diff --git a/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m b/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m index 4ab12b6..b9aa27f 100644 --- a/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m +++ b/XLPagerTabStrip/XL/Controllers/XLTwitterPagerTabStripViewController.m @@ -142,7 +142,7 @@ updateIndicatorFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex withProgressPercentage:(CGFloat)progressPercentage - andChangeCurrentIndex:(BOOL)changeCurrentIndex + indexWasChanged:(BOOL)indexWasChanged { CGFloat distance = [self getDistanceValue]; UIAccelerationValue xOffset = fromIndex < toIndex ? distance * fromIndex + distance * progressPercentage : distance * fromIndex - distance * progressPercentage;