Merge pull request #43 from xmartlabs/issue#4

issue #4 - Change the look and feel of a XLButtonBarViewCell based on the selected state
This commit is contained in:
Martin Barreto 2015-08-01 19:56:18 -03:00
commit eee769bb3f
13 changed files with 108 additions and 24 deletions

View File

@ -43,6 +43,16 @@ FAQ
-(void)moveToViewController:(UIViewController *)viewController;
```
#####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.
```objc
@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
--------------------------
@ -75,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

View File

@ -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'

View File

@ -78,13 +78,13 @@
28B63AD21A45A4CD00225C66 /* XLButtonBarViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLButtonBarViewCell.h; sourceTree = "<group>"; };
28B63AD31A45A4CD00225C66 /* XLButtonBarViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLButtonBarViewCell.m; sourceTree = "<group>"; };
28B63AE71A45B26600225C66 /* XLBarPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLBarPagerTabStripViewController.h; path = Controllers/XLBarPagerTabStripViewController.h; sourceTree = "<group>"; };
28B63AE81A45B26600225C66 /* XLBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLBarPagerTabStripViewController.m; path = Controllers/XLBarPagerTabStripViewController.m; sourceTree = "<group>"; };
28B63AE81A45B26600225C66 /* XLBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLBarPagerTabStripViewController.m; path = Controllers/XLBarPagerTabStripViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
28B63AE91A45B26600225C66 /* XLButtonBarPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLButtonBarPagerTabStripViewController.h; path = Controllers/XLButtonBarPagerTabStripViewController.h; sourceTree = "<group>"; };
28B63AEA1A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLButtonBarPagerTabStripViewController.m; path = Controllers/XLButtonBarPagerTabStripViewController.m; sourceTree = "<group>"; };
28B63AEA1A45B26600225C66 /* XLButtonBarPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLButtonBarPagerTabStripViewController.m; path = Controllers/XLButtonBarPagerTabStripViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
28B63AEB1A45B26600225C66 /* XLPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLPagerTabStripViewController.h; path = Controllers/XLPagerTabStripViewController.h; sourceTree = "<group>"; };
28B63AEC1A45B26600225C66 /* XLPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLPagerTabStripViewController.m; path = Controllers/XLPagerTabStripViewController.m; sourceTree = "<group>"; };
28B63AEC1A45B26600225C66 /* XLPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLPagerTabStripViewController.m; path = Controllers/XLPagerTabStripViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
28B63AED1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLSegmentedPagerTabStripViewController.h; path = Controllers/XLSegmentedPagerTabStripViewController.h; sourceTree = "<group>"; };
28B63AEE1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLSegmentedPagerTabStripViewController.m; path = Controllers/XLSegmentedPagerTabStripViewController.m; sourceTree = "<group>"; };
28B63AEE1A45B26600225C66 /* XLSegmentedPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLSegmentedPagerTabStripViewController.m; path = Controllers/XLSegmentedPagerTabStripViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
28B63AF31A465E5E00225C66 /* ReloadExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReloadExampleViewController.h; sourceTree = "<group>"; };
28B63AF41A465E5E00225C66 /* ReloadExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReloadExampleViewController.m; sourceTree = "<group>"; };
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 = "<group>"; };
6624E45B1AEEF9A50076274D /* NavButtonBarExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavButtonBarExampleViewController.m; sourceTree = "<group>"; };
66CA35B21A8D174900564221 /* XLTwitterPagerTabStripViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLTwitterPagerTabStripViewController.h; path = Controllers/XLTwitterPagerTabStripViewController.h; sourceTree = "<group>"; };
66CA35B31A8D174900564221 /* XLTwitterPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLTwitterPagerTabStripViewController.m; path = Controllers/XLTwitterPagerTabStripViewController.m; sourceTree = "<group>"; };
66CA35B31A8D174900564221 /* XLTwitterPagerTabStripViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XLTwitterPagerTabStripViewController.m; path = Controllers/XLTwitterPagerTabStripViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
C262204C1AD44A4D002E5226 /* TwitterExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TwitterExampleViewController.h; sourceTree = "<group>"; };
C262204D1AD44A4D002E5226 /* TwitterExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TwitterExampleViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

View File

@ -1,21 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="XLButtonBarViewCell">
<rect key="frame" x="0.0" y="0.0" width="80" height="40"/>
<rect key="frame" x="0.0" y="0.0" width="81" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4bA-d3-zGi">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4bA-d3-zGi">
<rect key="frame" x="19" y="10" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>

View File

@ -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

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ptL-BW-nEP">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ptL-BW-nEP">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>

View File

@ -90,6 +90,7 @@
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage
indexWasChanged:(BOOL)indexWasChanged
{
[self.barView moveFromIndex:fromIndex
toIndex:toIndex

View File

@ -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 indexWasChanged, BOOL fromCellRowAtIndex);
@property (copy) void (^changeCurrentIndexBlock)(XLButtonBarViewCell* oldCell, XLButtonBarViewCell *newCell, BOOL animated);
@property (readonly, nonatomic) XLButtonBarView * buttonBarView;
@end

View File

@ -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];
}
@ -123,6 +122,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 +134,18 @@
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage
indexWasChanged:(BOOL)indexWasChanged
{
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, indexWasChanged, YES);
}
}
}
@ -159,7 +170,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
@ -169,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)];
}
@ -182,6 +207,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;
}

View File

@ -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
indexWasChanged:(BOOL)indexWasChanged;
@end

View File

@ -186,6 +186,7 @@
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage
indexWasChanged:(BOOL)indexWasChanged
{
}
@ -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:indexWasChanged:)]){
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 )) indexWasChanged:changeCurrentIndex];
}
}
}

View File

@ -135,6 +135,7 @@
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage
indexWasChanged:(BOOL)indexWasChanged
{
if (self.shouldUpdateSegmentedControl){
NSInteger currentIndex = (progressPercentage > 0.5) ? toIndex : fromIndex;

View File

@ -142,6 +142,7 @@
updateIndicatorFromIndex:(NSInteger)fromIndex
toIndex:(NSInteger)toIndex
withProgressPercentage:(CGFloat)progressPercentage
indexWasChanged:(BOOL)indexWasChanged
{
CGFloat distance = [self getDistanceValue];
UIAccelerationValue xOffset = fromIndex < toIndex ? distance * fromIndex + distance * progressPercentage : distance * fromIndex - distance * progressPercentage;