From dd782587d96854214d47c5373fe6f094287c44ac Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Fri, 19 Feb 2016 07:48:00 -0800 Subject: [PATCH 01/21] added more functionality --- .../ESTabBarController+Autolayout.m | 76 ++++++++---- Source/Categories/UIButton+ESTabBar.h | 3 +- Source/Categories/UIButton+ESTabBar.m | 23 ++-- Source/Controllers/ESTabBarController.h | 11 ++ Source/Controllers/ESTabBarController.m | 114 ++++++++++-------- 5 files changed, 143 insertions(+), 84 deletions(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index 007f19e..326e71e 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -29,9 +29,15 @@ @implementation ESTabBarController (Autolayout) - (void)setupButtonsConstraints { + + // In case dumb user doesn't know math + if(self.widthPercentages!=nil && self.widthPercentages.count + != self.tabIcons.count && [[self.widthPercentages valueForKeyPath:@"@sum.self"] floatValue] != 1.0) { + self.widthPercentages = nil; + } for (NSInteger i = 0; i < self.tabIcons.count; i++) { [self.buttons[i] setTranslatesAutoresizingMaskIntoConstraints:NO]; - + [self.view addConstraints:[self leftLayoutConstraintsForButtonAtIndex:i]]; [self.view addConstraints:[self verticalLayoutConstraintsForButtonAtIndex:i]]; [self.view addConstraint:[self widthLayoutConstraintForButtonAtIndex:i]]; @@ -42,7 +48,7 @@ - (void)setupButtonsConstraints { - (void)setupSelectionIndicatorConstraints { self.selectionIndicatorLeadingConstraint = [self leadingLayoutConstraintForIndicator]; - + [self.buttonsContainer addConstraint:self.selectionIndicatorLeadingConstraint]; [self.buttonsContainer addConstraints:[self widthLayoutConstraintsForIndicator]]; [self.buttonsContainer addConstraints:[self heightLayoutConstraintsForIndicator]]; @@ -52,13 +58,13 @@ - (void)setupSelectionIndicatorConstraints { - (void)setupConstraintsForChildController:(UIViewController *)controller { NSDictionary *views = @{@"view": controller.view}; - + NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[view]-0-|" options:0 metrics:nil views:views]; [self.controllersContainer addConstraints:horizontalConstraints]; - + NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[view]-0-|" options:0 metrics:nil @@ -73,7 +79,7 @@ - (void)setupConstraintsForChildController:(UIViewController *)controller { - (NSArray *)leftLayoutConstraintsForButtonAtIndex:(NSInteger)index { UIButton *button = self.buttons[index]; NSArray *leftConstraints; - + if (index == 0) { // First button. Stick it to its left margin. leftConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-(0)-[button]" @@ -83,21 +89,21 @@ - (NSArray *)leftLayoutConstraintsForButtonAtIndex:(NSInteger)index { } else { NSDictionary *views = @{@"previousButton": self.buttons[index - 1], @"button": button}; - + // Stick the button to the previous one. leftConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"[previousButton]-(0)-[button]" options:0 metrics:nil views:views]; } - + return leftConstraints; } - (NSArray *)verticalLayoutConstraintsForButtonAtIndex:(NSInteger)index { UIButton *button = self.buttons[index]; - + // The button is sticked to its top and bottom margins. return [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(0)-[button]" options:0 @@ -108,20 +114,24 @@ - (NSArray *)verticalLayoutConstraintsForButtonAtIndex:(NSInteger)index { - (NSLayoutConstraint *)widthLayoutConstraintForButtonAtIndex:(NSInteger)index { UIButton *button = self.buttons[index]; - + CGFloat width = 1.0/self.buttons.count; + if (self.widthPercentages) { + width = [[self.widthPercentages objectAtIndex:index] floatValue]; + } + return [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.buttonsContainer attribute:NSLayoutAttributeWidth - multiplier:1.0 / self.buttons.count + multiplier:width constant:0.0]; } - (NSLayoutConstraint *)heightLayoutConstraintForButtonAtIndex:(NSInteger)index { UIButton *button = self.buttons[index]; - + return [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual @@ -133,23 +143,39 @@ - (NSLayoutConstraint *)heightLayoutConstraintForButtonAtIndex:(NSInteger)index - (NSLayoutConstraint *)leadingLayoutConstraintForIndicator { - NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-(0)-[selectionIndicator]" - options:0 - metrics:nil - views:@{@"selectionIndicator": self.selectionIndicator}]; + if(self.indicatorSizeRationalToIcon){ + return [NSLayoutConstraint constraintWithItem:self.selectionIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.buttons[0] attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]; + } else { + NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-(0)-[selectionIndicator]" + options:0 + metrics:nil + views:@{@"selectionIndicator": self.selectionIndicator}]; + + return [constraints firstObject]; + } - return [constraints firstObject]; } - (NSArray *)widthLayoutConstraintsForIndicator { - NSDictionary *views = @{@"button": self.buttons[0], - @"selectionIndicator": self.selectionIndicator}; - - return [NSLayoutConstraint constraintsWithVisualFormat:@"[selectionIndicator(==button)]" - options:0 - metrics:nil - views:views]; + if(self.indicatorSizeRationalToIcon){ + return @[[NSLayoutConstraint constraintWithItem:self.selectionIndicator + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:[self.buttons[0] valueForKey:@"imageView"] + attribute:NSLayoutAttributeWidth + multiplier:1.0 + constant:0.0]]; + } else { + NSDictionary *views = @{@"button": self.buttons[0], + @"selectionIndicator": self.selectionIndicator}; + + return [NSLayoutConstraint constraintsWithVisualFormat:@"[selectionIndicator(==button)]" + options:0 + metrics:nil + views:views]; + + } } @@ -161,12 +187,12 @@ - (NSArray *)heightLayoutConstraintsForIndicator { } +//TODO: BEFORE CREATING A FULL REQUEST WITH THE FORK RETURN THE VALUE HERE TO ZERO - (NSArray *)bottomLayoutConstraintsForIndicator { - return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(0)-|" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(2)-|" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; } - @end diff --git a/Source/Categories/UIButton+ESTabBar.h b/Source/Categories/UIButton+ESTabBar.h index 1f4e3f3..0ba1e2d 100644 --- a/Source/Categories/UIButton+ESTabBar.h +++ b/Source/Categories/UIButton+ESTabBar.h @@ -13,6 +13,7 @@ - (void)customizeForTabBarWithImage:(UIImage *)image selectedColor:(UIColor *)selectedColor - highlighted:(BOOL)highlighted; + highlighted:(BOOL)highlighted + backgroundColor:(UIColor *)backgroundColor; @end diff --git a/Source/Categories/UIButton+ESTabBar.m b/Source/Categories/UIButton+ESTabBar.m index adcb65a..24c971a 100644 --- a/Source/Categories/UIButton+ESTabBar.m +++ b/Source/Categories/UIButton+ESTabBar.m @@ -17,10 +17,11 @@ @implementation UIButton (ESTabBar) - (void)customizeForTabBarWithImage:(UIImage *)image selectedColor:(UIColor *)selectedColor - highlighted:(BOOL)highlighted { + highlighted:(BOOL)highlighted + backgroundColor:(UIColor *)backgroundColor { if (highlighted) { [self customizeAsHighlightedButtonForTabBarWithImage:image - selectedColor:selectedColor]; + backgroundColor:backgroundColor]; } else { [self customizeAsNormalButtonForTabBarWithImage:image selectedColor:selectedColor]; @@ -32,34 +33,34 @@ - (void)customizeForTabBarWithImage:(UIImage *)image - (void)customizeAsHighlightedButtonForTabBarWithImage:(UIImage *)image - selectedColor:(UIColor *)selectedColor { - + backgroundColor:(UIColor *)backgroundColor { + // We want the image to be always white in highlighted state. self.tintColor = [UIColor whiteColor]; - [self setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] + [self setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; - + // And its background color should always be the selected color. - self.backgroundColor = selectedColor; + self.backgroundColor = backgroundColor; } - (void)customizeAsNormalButtonForTabBarWithImage:(UIImage *)image selectedColor:(UIColor *)selectedColor { - + // The tint color is the one used for selected state. self.tintColor = selectedColor; - + // When the button is not selected, we show the image always with its // original color. [self setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; - + // When the button is selected, we apply the tint color using the // always template mode. [self setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateSelected]; - + // We don't want a background color to use the one in the tab bar. self.backgroundColor = [UIColor clearColor]; } diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index 2668f0f..25fe860 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -20,6 +20,9 @@ typedef void (^ESTabBarAction)(void); /// Background color for the view that contains the buttons. @property (nonatomic, strong) UIColor *buttonsBackgroundColor; +/// The color of the selectedButton background +@property (nonatomic, strong) UIColor *selectedBackgroundColor; + /// The index (starting from 0) of the view controller being shown. @property (nonatomic, readonly) NSInteger selectedIndex; @@ -34,6 +37,12 @@ typedef void (^ESTabBarAction)(void); @property (nonatomic, assign) BOOL highlightsSelectedButton; +// Array with all widths of buttons +@property (nonatomic,strong) NSMutableArray *widthPercentages; + +@property (nonatomic,assign) BOOL indicatorSizeRationalToIcon; + + /** Initializes the tab bar with an array of UIImage that will be the icons to show in the tab bar. @@ -88,5 +97,7 @@ typedef void (^ESTabBarAction)(void); */ - (void)setSelectedIndex:(NSInteger)selectedIndex animated:(BOOL)animated; +- (void)setIconImageAtIndex:(NSInteger)selectedIndex icon:(UIImage *)icon; + @end diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index e8f903d..44190d9 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -42,22 +42,22 @@ @implementation ESTabBarController - (instancetype)initWithTabIcons:(NSArray *)tabIcons { NSBundle *bundle = [NSBundle bundleForClass:[self class]]; self = [self initWithNibName:@"ESTabBarController" bundle:bundle]; - + if (self != nil) { [self initializeWithTabIcons:tabIcons]; } - + return self; } - (instancetype)initWithTabIconNames:(NSArray *)tabIconNames { NSMutableArray *icons = [NSMutableArray array]; - + for (NSString *name in tabIconNames) { [icons addObject:[UIImage imageNamed:name]]; } - + return [self initWithTabIcons:icons]; } @@ -69,20 +69,28 @@ - (void)setSelectedColor:(UIColor *)selectedColor { if (_selectedColor != selectedColor) { _selectedColor = selectedColor; } - + [self updateInterfaceIfNeeded]; - + // Select the current button again to reflect the color change. UIButton *selectedButton = self.buttons[self.selectedIndex]; selectedButton.selected = YES; } +- (void)setSelectedBackgroundColor:(UIColor *)color { + if (_selectedBackgroundColor != color) { + _selectedBackgroundColor = color; + } + + [self updateInterfaceIfNeeded]; +} + - (void)setSeparatorLineVisible:(BOOL)visible { if (_separatorLineVisible != visible) { _separatorLineVisible = visible; } - + [self setupSeparatorLine]; } @@ -91,7 +99,7 @@ - (void)setSeparatorLineColor:(UIColor *)color { if (_separatorLineColor != color) { _separatorLineColor = color; } - + self.separatorLine.backgroundColor = color; } @@ -107,7 +115,7 @@ - (void)viewDidLoad { - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - + if (self.selectedIndex == -1) { // We only setup everything if there isn't any selected index. [self setupInterface]; @@ -140,14 +148,14 @@ - (void)highlightButtonAtIndex:(NSInteger)index { - (void)setButtonTintColor:(UIColor *)color atIndex:(NSInteger)index { if (![self.highlightedButtonIndexes containsObject:@(index)]) { UIButton *button = self.buttons[index]; - + button.tintColor = color; - + UIImage *buttonImage = [button imageForState:UIControlStateNormal]; - + [button setImage:[buttonImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal]; - + [button setImage:[buttonImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateSelected]; } @@ -159,7 +167,7 @@ - (void)setBarHidden:(BOOL)hidden animated:(BOOL)animated { self.buttonsContainerHeightConstraint.constant = hidden ? 0 : self.buttonsContainerHeightConstraintInitialConstant; [self.view layoutIfNeeded]; }; - + if (animated) { [self.view layoutIfNeeded]; [UIView animateWithDuration:0.5 animations:animations]; @@ -172,7 +180,7 @@ - (void)setBarHidden:(BOOL)hidden animated:(BOOL)animated { - (void)setSelectedIndex:(NSInteger)selectedIndex animated:(BOOL)animated { // Show the selected view controller. [self moveToControllerAtIndex:selectedIndex animated:animated]; - + // Run the action if necessary. void (^action)(void) = self.actions[@(selectedIndex)]; if (action != nil) { @@ -180,13 +188,21 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex animated:(BOOL)animated { } } +- (void)setIconImageAtIndex:(NSInteger)selectedIndex icon:(UIImage *)icon { + //[self.tabIcons replaceObjectAtIndex:selectedIndex withObject:icon]; + NSMutableArray *mutablearr = [self.tabIcons mutableCopy]; + mutablearr[selectedIndex] = icon; + self.tabIcons = [NSArray arrayWithArray:mutablearr]; + [self customizeButtonAtIndex:selectedIndex]; +} + #pragma mark - Actions - (void)tabButtonAction:(UIButton *)button { NSInteger index = [self.buttons indexOfObject:button]; - + if (index != NSNotFound) { [self setSelectedIndex:index animated:YES]; } @@ -199,17 +215,17 @@ - (void)tabButtonAction:(UIButton *)button { - (void)initializeWithTabIcons:(NSArray *)tabIcons { NSAssert(tabIcons.count > 0, @"The array of tab icons shouldn't be empty."); - + _tabIcons = tabIcons; - + self.controllers = [NSMutableDictionary dictionaryWithCapacity:tabIcons.count]; self.actions = [NSMutableDictionary dictionaryWithCapacity:tabIcons.count]; - + self.highlightedButtonIndexes = [NSMutableSet set]; - + // No selected index at first. _selectedIndex = -1; - + self.separatorLineColor = [UIColor lightGrayColor]; } @@ -233,17 +249,17 @@ - (void)setupInterface { - (void)setupButtons { if (self.buttons == nil) { self.buttons = [NSMutableArray arrayWithCapacity:self.tabIcons.count]; - + for (NSInteger i = 0; i < self.tabIcons.count; i++) { UIButton *button = [self createButtonForIndex:i]; - + [self.buttonsContainer addSubview:button]; self.buttons[i] = button; } - + [self setupButtonsConstraints]; } - + [self customizeButtons]; self.buttonsContainer.backgroundColor = self.buttonsBackgroundColor ?: [UIColor lightGrayColor]; } @@ -251,44 +267,48 @@ - (void)setupButtons { - (UIButton *)createButtonForIndex:(NSInteger)index { UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - + [button addTarget:self action:@selector(tabButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - + return button; } - (void)customizeButtons { for (NSInteger i = 0; i < self.tabIcons.count; i++) { - UIButton *button = self.buttons[i]; - - BOOL isHighlighted = [self.highlightedButtonIndexes containsObject:@(i)]; - [button customizeForTabBarWithImage:self.tabIcons[i] - selectedColor:self.selectedColor ?: [UIColor blackColor] - highlighted:isHighlighted]; - + [self customizeButtonAtIndex:i]; } } +- (void) customizeButtonAtIndex:(NSInteger)index { + UIButton *button = self.buttons[index]; + + BOOL isHighlighted = [self.highlightedButtonIndexes containsObject:@(index)]; + [button customizeForTabBarWithImage:self.tabIcons[index] + selectedColor:self.selectedColor ?: [UIColor blackColor] + highlighted:isHighlighted + backgroundColor:self.selectedBackgroundColor ?: nil]; +} + - (void)moveToControllerAtIndex:(NSInteger)index animated:(BOOL)animated { if (self.selectedIndex == index) { // Nothing to do. return; } - + UIViewController *controller = self.controllers[@(index)]; - + if (controller != nil) { // Deselect all the buttons excepting the selected one. for (NSInteger i = 0; i < self.buttons.count; i++) { UIButton *button = self.buttons[i]; - + BOOL selected = (i == index); button.selected = selected; - + if (self.highlightsSelectedButton && !(self.actions[@(i)] != nil && self.controllers[@(i)] == nil)) { // Only if the selected button highlighting is enabled and // the button either has a controller, or a controller and an @@ -296,19 +316,19 @@ - (void)moveToControllerAtIndex:(NSInteger)index animated:(BOOL)animated { button.alpha = selected ? 1.0 : 0.5; } } - + if (self.selectedIndex >= 0) { // Remove the current controller's view. UIViewController *currentController = self.controllers[@(self.selectedIndex)]; [currentController.view removeFromSuperview]; } - + if (![self.childViewControllers containsObject:controller]) { // If I haven't added the controller to the childs yet... [self addChildViewController:controller]; [controller didMoveToParentViewController:self]; } - + if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) { // Table views have an issue when disabling autoresizing // constraints in iOS 7. @@ -324,9 +344,9 @@ - (void)moveToControllerAtIndex:(NSInteger)index animated:(BOOL)animated { [self.controllersContainer addSubview:controller.view]; [self setupConstraintsForChildController:controller]; } - + [self moveSelectionIndicatorToIndex:index animated:animated]; - + _selectedIndex = index; } } @@ -337,10 +357,10 @@ - (void)setupSelectionIndicator { self.selectionIndicator = [[UIView alloc] init]; self.selectionIndicator.translatesAutoresizingMaskIntoConstraints = NO; [self.buttonsContainer addSubview:self.selectionIndicator]; - + [self setupSelectionIndicatorConstraints]; } - + self.selectionIndicator.backgroundColor = self.selectedColor ?: [UIColor blackColor]; } @@ -354,13 +374,13 @@ - (void)setupSeparatorLine { - (void)moveSelectionIndicatorToIndex:(NSInteger)index animated:(BOOL)animated { CGFloat constant = [self.buttons[index] frame].origin.x; - + [self.buttonsContainer layoutIfNeeded]; void (^animations)(void) = ^{ self.selectionIndicatorLeadingConstraint.constant = constant; [self.buttonsContainer layoutIfNeeded]; }; - + if (animated) { [UIView animateWithDuration:0.25 delay:0.0 From c7a38b9d9c51567360977b47b893f6462c4ab267 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Mon, 22 Feb 2016 10:52:41 -0800 Subject: [PATCH 02/21] changed height of indicator --- Source/Categories/ESTabBarController+Autolayout.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index 326e71e..dbe1e77 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -179,8 +179,9 @@ - (NSArray *)widthLayoutConstraintsForIndicator { } +//TODO: BEFORE CREATING A FULL REQUEST WITH THE FORK RETURN THE VALUE HERE TO THREE - (NSArray *)heightLayoutConstraintsForIndicator { - return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==3)]" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==2)]" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; From 3408a9be1cbe7870082d0a6239b08f384465243c Mon Sep 17 00:00:00 2001 From: edenfisher Date: Sun, 24 Apr 2016 00:57:38 +0300 Subject: [PATCH 03/21] Update ESTabBarController.h added documentaion --- Source/Controllers/ESTabBarController.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index 25fe860..8dc9e03 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -97,6 +97,9 @@ typedef void (^ESTabBarAction)(void); */ - (void)setSelectedIndex:(NSInteger)selectedIndex animated:(BOOL)animated; +/** + Changes icon image at specific index. + */ - (void)setIconImageAtIndex:(NSInteger)selectedIndex icon:(UIImage *)icon; From bd54b07aac5da982371008137639c914db219c01 Mon Sep 17 00:00:00 2001 From: edenfisher Date: Sun, 24 Apr 2016 00:59:21 +0300 Subject: [PATCH 04/21] Update ESTabBarController.m remove unwanted commented code. --- Source/Controllers/ESTabBarController.m | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index 44190d9..00434fa 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -189,7 +189,6 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex animated:(BOOL)animated { } - (void)setIconImageAtIndex:(NSInteger)selectedIndex icon:(UIImage *)icon { - //[self.tabIcons replaceObjectAtIndex:selectedIndex withObject:icon]; NSMutableArray *mutablearr = [self.tabIcons mutableCopy]; mutablearr[selectedIndex] = icon; self.tabIcons = [NSArray arrayWithArray:mutablearr]; From fc8876350d2cd4cf7b9ac908678512ef5a2c6e1f Mon Sep 17 00:00:00 2001 From: edenfisher Date: Sun, 24 Apr 2016 01:02:02 +0300 Subject: [PATCH 05/21] Update ESTabBarController.h add more documentation --- Source/Controllers/ESTabBarController.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index 8dc9e03..5b05eb2 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -37,9 +37,10 @@ typedef void (^ESTabBarAction)(void); @property (nonatomic, assign) BOOL highlightsSelectedButton; -// Array with all widths of buttons +/// Array with all widths of the buttons. Enables to determine the width of each button in the tab bar. @property (nonatomic,strong) NSMutableArray *widthPercentages; +/// Sets the small indicator size to be rational to the size of the icon. @property (nonatomic,assign) BOOL indicatorSizeRationalToIcon; From a584842c2eb3d126406c02e72e2a0f7b877d6b5c Mon Sep 17 00:00:00 2001 From: edenfisher Date: Sun, 24 Apr 2016 01:05:39 +0300 Subject: [PATCH 06/21] Update ESTabBarController.h small change to property name. --- Source/Controllers/ESTabBarController.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index 5b05eb2..a7733a0 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -20,8 +20,8 @@ typedef void (^ESTabBarAction)(void); /// Background color for the view that contains the buttons. @property (nonatomic, strong) UIColor *buttonsBackgroundColor; -/// The color of the selectedButton background -@property (nonatomic, strong) UIColor *selectedBackgroundColor; +/// The color of the highlited button background +@property (nonatomic, strong) UIColor *highlightedBackgroundColor; /// The index (starting from 0) of the view controller being shown. @property (nonatomic, readonly) NSInteger selectedIndex; From b46275699525d6bb2fef0fefcb6b65348f0a5324 Mon Sep 17 00:00:00 2001 From: edenfisher Date: Sun, 24 Apr 2016 01:14:08 +0300 Subject: [PATCH 07/21] Update ESTabBarController.h revert change to property name for now --- Source/Controllers/ESTabBarController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index a7733a0..da7a90b 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -21,7 +21,7 @@ typedef void (^ESTabBarAction)(void); @property (nonatomic, strong) UIColor *buttonsBackgroundColor; /// The color of the highlited button background -@property (nonatomic, strong) UIColor *highlightedBackgroundColor; +@property (nonatomic, strong) UIColor *selectedBackgroundColor; /// The index (starting from 0) of the view controller being shown. @property (nonatomic, readonly) NSInteger selectedIndex; From 6791a4373bc853224aa862809bc5e8fc9bebd402 Mon Sep 17 00:00:00 2001 From: galharth Date: Fri, 7 Oct 2016 09:57:48 +0300 Subject: [PATCH 08/21] Update ESTabBarController.h --- Source/Controllers/ESTabBarController.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index da7a90b..1a72417 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -64,6 +64,8 @@ typedef void (^ESTabBarAction)(void); - (void)setViewController:(UIViewController *)viewController atIndex:(NSInteger)index; +- (UIView *)getButtonsContianer; + /** Sets an action to be fired when tapping a button at a specific index. If there is also a view controller set at that index, the action is fired immediately From 8c6c3525f213aed373921587f1207da98e9d54e3 Mon Sep 17 00:00:00 2001 From: galharth Date: Fri, 7 Oct 2016 09:58:34 +0300 Subject: [PATCH 09/21] Update ESTabBarController.m --- Source/Controllers/ESTabBarController.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index 00434fa..dac85a8 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -144,6 +144,9 @@ - (void)highlightButtonAtIndex:(NSInteger)index { [self updateInterfaceIfNeeded]; } +- (UIView *)getButtonsContianer { + return self.buttonsContainer; +} - (void)setButtonTintColor:(UIColor *)color atIndex:(NSInteger)index { if (![self.highlightedButtonIndexes containsObject:@(index)]) { From 76f7209455ff8c551b018641ee0acc343c71ce02 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sat, 8 Oct 2016 17:04:11 +0300 Subject: [PATCH 10/21] added delegate --- Source/Controllers/ESTabBarController.m | 7 +++++-- Source/Protocols/ESTabBarDelegate.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 Source/Protocols/ESTabBarDelegate.h diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index dac85a8..0930937 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -9,9 +9,12 @@ #import "ESTabBarController.h" #import "UIButton+ESTabBar.h" #import "ESTabBarController+Autolayout.h" +#import "ESTabBarDelegate.h" -@interface ESTabBarController () +@interface ESTabBarController:NSObject () + +@property (nonatomic, weak) id delegate; @property (nonatomic, weak) IBOutlet UIView *controllersContainer; @property (nonatomic, weak) IBOutlet UIView *buttonsContainer; @@ -297,7 +300,7 @@ - (void) customizeButtonAtIndex:(NSInteger)index { - (void)moveToControllerAtIndex:(NSInteger)index animated:(BOOL)animated { if (self.selectedIndex == index) { - // Nothing to do. + [self delegate tabClickedTwice:index] return; } diff --git a/Source/Protocols/ESTabBarDelegate.h b/Source/Protocols/ESTabBarDelegate.h new file mode 100644 index 0000000..60e0db8 --- /dev/null +++ b/Source/Protocols/ESTabBarDelegate.h @@ -0,0 +1,4 @@ +#import +@protocol ESTabBarDelegate +- (NSInteger)tabClickedTwice; +@end From a4fe7d13df14806697f415e83e94355453e79919 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sat, 8 Oct 2016 17:23:47 +0300 Subject: [PATCH 11/21] small fix to delegate implementation --- Source/Controllers/ESTabBarController.m | 2 +- Source/Protocols/ESTabBarDelegate.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index 0930937..d07e9d6 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -12,7 +12,7 @@ #import "ESTabBarDelegate.h" -@interface ESTabBarController:NSObject () +@interface ESTabBarController () @property (nonatomic, weak) id delegate; diff --git a/Source/Protocols/ESTabBarDelegate.h b/Source/Protocols/ESTabBarDelegate.h index 60e0db8..991ae73 100644 --- a/Source/Protocols/ESTabBarDelegate.h +++ b/Source/Protocols/ESTabBarDelegate.h @@ -1,4 +1,4 @@ -#import -@protocol ESTabBarDelegate +#import +@protocol ESTabBarDelegate - (NSInteger)tabClickedTwice; @end From 6563504a3987188dca5f81fee3bdf2f1211ec81a Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sat, 8 Oct 2016 18:47:06 +0300 Subject: [PATCH 12/21] small fix --- Source/Controllers/ESTabBarController.m | 2 +- Source/Protocols/ESTabBarDelegate.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index d07e9d6..ae3d84e 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -300,7 +300,7 @@ - (void) customizeButtonAtIndex:(NSInteger)index { - (void)moveToControllerAtIndex:(NSInteger)index animated:(BOOL)animated { if (self.selectedIndex == index) { - [self delegate tabClickedTwice:index] + [self.delegate tabClickedTwice:index]; return; } diff --git a/Source/Protocols/ESTabBarDelegate.h b/Source/Protocols/ESTabBarDelegate.h index 991ae73..0f3b50f 100644 --- a/Source/Protocols/ESTabBarDelegate.h +++ b/Source/Protocols/ESTabBarDelegate.h @@ -1,4 +1,4 @@ #import -@protocol ESTabBarDelegate +@protocol ESTabBarDelegate - (NSInteger)tabClickedTwice; @end From a20ae1bfd19a038b028d8c3327eedde7f6334d8d Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sat, 8 Oct 2016 19:25:15 +0300 Subject: [PATCH 13/21] change delegate implementation --- Source/Controllers/ESTabBarController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index ae3d84e..6f2ed88 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -14,7 +14,7 @@ @interface ESTabBarController () -@property (nonatomic, weak) id delegate; +@property (nonatomic, assign) id delegate; @property (nonatomic, weak) IBOutlet UIView *controllersContainer; @property (nonatomic, weak) IBOutlet UIView *buttonsContainer; From 28c31054307dc873152e9b3051b5c89b9515cdcc Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sat, 8 Oct 2016 19:28:23 +0300 Subject: [PATCH 14/21] small fix --- Source/Protocols/ESTabBarDelegate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Protocols/ESTabBarDelegate.h b/Source/Protocols/ESTabBarDelegate.h index 0f3b50f..da76aa3 100644 --- a/Source/Protocols/ESTabBarDelegate.h +++ b/Source/Protocols/ESTabBarDelegate.h @@ -1,4 +1,4 @@ #import @protocol ESTabBarDelegate -- (NSInteger)tabClickedTwice; +- (void)tabClickedTwice:(NSInteger)index; @end From ea40f7001672c10d1562785fa1aa7fe61eac80cb Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sat, 8 Oct 2016 19:36:09 +0300 Subject: [PATCH 15/21] small fix to delegate not being public --- Source/Controllers/ESTabBarController.h | 2 ++ Source/Controllers/ESTabBarController.m | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index 1a72417..4106e40 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -7,12 +7,14 @@ // #import +#import "ESTabBarDelegate.h" typedef void (^ESTabBarAction)(void); @interface ESTabBarController : UIViewController +@property (nonatomic, assign) id delegate; /// Color to use for when a tab bar button is selected. @property (nonatomic, strong) UIColor *selectedColor; diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index 6f2ed88..1bed925 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -14,8 +14,6 @@ @interface ESTabBarController () -@property (nonatomic, assign) id delegate; - @property (nonatomic, weak) IBOutlet UIView *controllersContainer; @property (nonatomic, weak) IBOutlet UIView *buttonsContainer; @property (nonatomic, weak) IBOutlet UIView *separatorLine; From 9f1bd539b666cd543feec3b81e3652fa44dea581 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sun, 16 Oct 2016 16:43:31 +0300 Subject: [PATCH 16/21] added some fixes and docs --- .../Categories/ESTabBarController+Autolayout.m | 17 +++-------------- Source/Controllers/ESTabBarController.h | 8 ++++++-- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index dbe1e77..4071619 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -37,7 +37,6 @@ - (void)setupButtonsConstraints { } for (NSInteger i = 0; i < self.tabIcons.count; i++) { [self.buttons[i] setTranslatesAutoresizingMaskIntoConstraints:NO]; - [self.view addConstraints:[self leftLayoutConstraintsForButtonAtIndex:i]]; [self.view addConstraints:[self verticalLayoutConstraintsForButtonAtIndex:i]]; [self.view addConstraint:[self widthLayoutConstraintForButtonAtIndex:i]]; @@ -48,7 +47,6 @@ - (void)setupButtonsConstraints { - (void)setupSelectionIndicatorConstraints { self.selectionIndicatorLeadingConstraint = [self leadingLayoutConstraintForIndicator]; - [self.buttonsContainer addConstraint:self.selectionIndicatorLeadingConstraint]; [self.buttonsContainer addConstraints:[self widthLayoutConstraintsForIndicator]]; [self.buttonsContainer addConstraints:[self heightLayoutConstraintsForIndicator]]; @@ -58,13 +56,11 @@ - (void)setupSelectionIndicatorConstraints { - (void)setupConstraintsForChildController:(UIViewController *)controller { NSDictionary *views = @{@"view": controller.view}; - NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-0-[view]-0-|" options:0 metrics:nil views:views]; [self.controllersContainer addConstraints:horizontalConstraints]; - NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[view]-0-|" options:0 metrics:nil @@ -79,7 +75,6 @@ - (void)setupConstraintsForChildController:(UIViewController *)controller { - (NSArray *)leftLayoutConstraintsForButtonAtIndex:(NSInteger)index { UIButton *button = self.buttons[index]; NSArray *leftConstraints; - if (index == 0) { // First button. Stick it to its left margin. leftConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-(0)-[button]" @@ -89,21 +84,18 @@ - (NSArray *)leftLayoutConstraintsForButtonAtIndex:(NSInteger)index { } else { NSDictionary *views = @{@"previousButton": self.buttons[index - 1], @"button": button}; - // Stick the button to the previous one. leftConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"[previousButton]-(0)-[button]" options:0 metrics:nil views:views]; } - return leftConstraints; } - (NSArray *)verticalLayoutConstraintsForButtonAtIndex:(NSInteger)index { UIButton *button = self.buttons[index]; - // The button is sticked to its top and bottom margins. return [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(0)-[button]" options:0 @@ -131,7 +123,6 @@ - (NSLayoutConstraint *)widthLayoutConstraintForButtonAtIndex:(NSInteger)index { - (NSLayoutConstraint *)heightLayoutConstraintForButtonAtIndex:(NSInteger)index { UIButton *button = self.buttons[index]; - return [NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual @@ -143,22 +134,21 @@ - (NSLayoutConstraint *)heightLayoutConstraintForButtonAtIndex:(NSInteger)index - (NSLayoutConstraint *)leadingLayoutConstraintForIndicator { - if(self.indicatorSizeRationalToIcon){ + if(self.indicatorSizeRelativeToIcon){ return [NSLayoutConstraint constraintWithItem:self.selectionIndicator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.buttons[0] attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]; } else { NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-(0)-[selectionIndicator]" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; - return [constraints firstObject]; } - + } - (NSArray *)widthLayoutConstraintsForIndicator { - if(self.indicatorSizeRationalToIcon){ + if(self.indicatorSizeRelativeToIcon){ return @[[NSLayoutConstraint constraintWithItem:self.selectionIndicator attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual @@ -169,7 +159,6 @@ - (NSArray *)widthLayoutConstraintsForIndicator { } else { NSDictionary *views = @{@"button": self.buttons[0], @"selectionIndicator": self.selectionIndicator}; - return [NSLayoutConstraint constraintsWithVisualFormat:@"[selectionIndicator(==button)]" options:0 metrics:nil diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index 4106e40..4ce1b7c 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -14,6 +14,7 @@ typedef void (^ESTabBarAction)(void); @interface ESTabBarController : UIViewController +/// Delegate to expose some events from the tab bar @property (nonatomic, assign) id delegate; /// Color to use for when a tab bar button is selected. @@ -22,7 +23,7 @@ typedef void (^ESTabBarAction)(void); /// Background color for the view that contains the buttons. @property (nonatomic, strong) UIColor *buttonsBackgroundColor; -/// The color of the highlited button background +/// The color of the highlighted button background @property (nonatomic, strong) UIColor *selectedBackgroundColor; /// The index (starting from 0) of the view controller being shown. @@ -43,7 +44,7 @@ typedef void (^ESTabBarAction)(void); @property (nonatomic,strong) NSMutableArray *widthPercentages; /// Sets the small indicator size to be rational to the size of the icon. -@property (nonatomic,assign) BOOL indicatorSizeRationalToIcon; +@property (nonatomic,assign) BOOL indicatorSizeRelativeToIcon; /** @@ -66,6 +67,9 @@ typedef void (^ESTabBarAction)(void); - (void)setViewController:(UIViewController *)viewController atIndex:(NSInteger)index; +/** + Gets the button container view. Useful for onboarding for tab bar and etc. + */ - (UIView *)getButtonsContianer; /** From 739cab52c826091a915b8e2620c94a62b0dc93e5 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sun, 16 Oct 2016 16:44:13 +0300 Subject: [PATCH 17/21] changed some specific values was in place --- Source/Categories/ESTabBarController+Autolayout.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index 4071619..1c68e23 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -168,18 +168,16 @@ - (NSArray *)widthLayoutConstraintsForIndicator { } -//TODO: BEFORE CREATING A FULL REQUEST WITH THE FORK RETURN THE VALUE HERE TO THREE - (NSArray *)heightLayoutConstraintsForIndicator { - return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==2)]" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==3)]" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; } -//TODO: BEFORE CREATING A FULL REQUEST WITH THE FORK RETURN THE VALUE HERE TO ZERO - (NSArray *)bottomLayoutConstraintsForIndicator { - return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(2)-|" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(0)-|" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; From 4de40d7a4d8d377c2029152e2f632e73d4ae5215 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sun, 16 Oct 2016 17:11:03 +0300 Subject: [PATCH 18/21] fix naming and check some value change --- Source/Categories/ESTabBarController+Autolayout.m | 6 +++--- Source/Controllers/ESTabBarController.h | 2 +- Source/Controllers/ESTabBarController.m | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index 50747fd..fb19b55 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -170,18 +170,18 @@ - (NSArray *)widthLayoutConstraintsForIndicator { - (NSArray *)heightLayoutConstraintsForIndicator { - NSArray *heightConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==3)]" + NSArray *heightConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==2)]" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; self.selectionIndicatorHeightConstraint = [heightConstraints firstObject]; - + return heightConstraints; } - (NSArray *)bottomLayoutConstraintsForIndicator { - return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(0)-|" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(-2)-|" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; diff --git a/Source/Controllers/ESTabBarController.h b/Source/Controllers/ESTabBarController.h index eb87118..1ab057e 100644 --- a/Source/Controllers/ESTabBarController.h +++ b/Source/Controllers/ESTabBarController.h @@ -24,7 +24,7 @@ typedef void (^ESTabBarAction)(void); @property (nonatomic, strong) UIColor *buttonsBackgroundColor; /// The color of the highlighted button background -@property (nonatomic, strong) UIColor *selectedBackgroundColor; +@property (nonatomic, strong) UIColor *highlightedBackgroundColor; /// The index (starting from 0) of the view controller being shown. @property (nonatomic, readonly) NSInteger selectedIndex; diff --git a/Source/Controllers/ESTabBarController.m b/Source/Controllers/ESTabBarController.m index 04fddf6..ce1f39c 100644 --- a/Source/Controllers/ESTabBarController.m +++ b/Source/Controllers/ESTabBarController.m @@ -79,9 +79,9 @@ - (void)setSelectedColor:(UIColor *)selectedColor { selectedButton.selected = YES; } -- (void)setSelectedBackgroundColor:(UIColor *)color { - if (_selectedBackgroundColor != color) { - _selectedBackgroundColor = color; +- (void)sethighlightedBackgroundColor:(UIColor *)color { + if (_highlightedBackgroundColor != color) { + _highlightedBackgroundColor = color; } [self updateInterfaceIfNeeded]; @@ -335,7 +335,7 @@ - (void) customizeButtonAtIndex:(NSInteger)index { [button customizeForTabBarWithImage:self.tabIcons[index] selectedColor:self.selectedColor ?: [UIColor blackColor] highlighted:isHighlighted - backgroundColor:self.selectedBackgroundColor ?: nil]; + backgroundColor:self.highlightedBackgroundColor ?: nil]; } From e81b17eca1e722ff2d8c93603450e69f4e40cc80 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sun, 16 Oct 2016 17:16:20 +0300 Subject: [PATCH 19/21] small fix to value --- Source/Categories/ESTabBarController+Autolayout.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index fb19b55..760e270 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -181,7 +181,7 @@ - (NSArray *)heightLayoutConstraintsForIndicator { - (NSArray *)bottomLayoutConstraintsForIndicator { - return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(-2)-|" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(2)-|" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; From f5fca279c84c20d03d9cce806a18862645df0aa6 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sun, 16 Oct 2016 17:33:47 +0300 Subject: [PATCH 20/21] fixed some merge issue --- Source/Categories/ESTabBarController+Autolayout.m | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index 760e270..9c8beb7 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -170,18 +170,15 @@ - (NSArray *)widthLayoutConstraintsForIndicator { - (NSArray *)heightLayoutConstraintsForIndicator { - NSArray *heightConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==2)]" + return NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==3)]" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; - self.selectionIndicatorHeightConstraint = [heightConstraints firstObject]; - - return heightConstraints; } - (NSArray *)bottomLayoutConstraintsForIndicator { - return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(2)-|" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator]-(0)-|" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}]; From 3426f27f6b48a7a8cb2758d7d003fee3f9b38aa8 Mon Sep 17 00:00:00 2001 From: Eden Fisher Date: Sun, 16 Oct 2016 17:35:03 +0300 Subject: [PATCH 21/21] small syntax issue --- Source/Categories/ESTabBarController+Autolayout.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Categories/ESTabBarController+Autolayout.m b/Source/Categories/ESTabBarController+Autolayout.m index 9c8beb7..dd4541d 100644 --- a/Source/Categories/ESTabBarController+Autolayout.m +++ b/Source/Categories/ESTabBarController+Autolayout.m @@ -170,7 +170,7 @@ - (NSArray *)widthLayoutConstraintsForIndicator { - (NSArray *)heightLayoutConstraintsForIndicator { - return NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==3)]" + return [NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectionIndicator(==3)]" options:0 metrics:nil views:@{@"selectionIndicator": self.selectionIndicator}];