From b4149457784ce115e7b0533aab2fe7576b7be06f Mon Sep 17 00:00:00 2001 From: Grigory Lutkov Date: Sun, 26 Jul 2015 17:59:02 +0300 Subject: [PATCH] Fixed bug when 'plus' button doesn't change state after programmatically show/hide buttons --- LGPlusButtonsView/LGPlusButtonsView.m | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index 77a1c86..bd3db01 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -877,18 +877,10 @@ - (void)updatePosition - (void)plusButtonAction:(LGPlusButton *)button { - _plusButton.selected = !_plusButton.isSelected; - if (_plusButton.isSelected) - { - [self selectPlusButtonViewWithAnimationType:_plusButtonAnimationType animated:YES completionHandler:nil]; - [self showButtonsAnimated:YES completionHandler:nil]; - } - else - { - [self deselectPlusButtonViewWithAnimationType:_plusButtonAnimationType animated:YES completionHandler:nil]; [self hideButtonsAnimated:YES completionHandler:nil]; - } + else + [self showButtonsAnimated:YES completionHandler:nil]; if (_plusButtonActionHandler) _plusButtonActionHandler(self); @@ -1026,6 +1018,10 @@ - (void)showButtonsAnimated:(BOOL)animated completionHandler:(void(^)())completi { if (self.isShowsPlusButton) { + _plusButton.selected = YES; + + [self selectPlusButtonViewWithAnimationType:_plusButtonAnimationType animated:YES completionHandler:nil]; + NSTimeInterval delay = 0.03; for (NSInteger i=1; i<_buttons.count; i++) @@ -1067,6 +1063,10 @@ - (void)hideButtonsAnimated:(BOOL)animated completionHandler:(void(^)())completi { if (self.isShowsPlusButton) { + _plusButton.selected = NO; + + [self deselectPlusButtonViewWithAnimationType:_plusButtonAnimationType animated:YES completionHandler:nil]; + NSTimeInterval delay = 0.03; for (NSInteger i=1; i<_buttons.count; i++) @@ -1299,7 +1299,8 @@ - (void)selectPlusButtonViewWithAnimationType:(LGPlusButtonAnimationType)type an [UIView transitionWithView:plusButtonWrapperView2 duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve - animations:nil completion:completionHandler]; + animations:nil + completion:completionHandler]; } else if (type == LGPlusButtonAnimationTypeRotate) { @@ -1335,7 +1336,8 @@ - (void)deselectPlusButtonViewWithAnimationType:(LGPlusButtonAnimationType)type [UIView transitionWithView:plusButtonWrapperView2 duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve - animations:nil completion:completionHandler]; + animations:nil + completion:completionHandler]; } else if (type == LGPlusButtonAnimationTypeRotate) {