From 4a7b79d19f259ff2169d43fef71b0d161bfeeac9 Mon Sep 17 00:00:00 2001 From: AnatoliyPozdeyev Date: Fri, 24 Jun 2016 18:14:53 +0300 Subject: [PATCH 1/8] Hidden buttons don't process taps. --- LGPlusButtonsView/LGPlusButtonsView.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index 2f76fc2..3fe1565 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -313,8 +313,16 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event UIView *view = nil; - for (LGPlusButton *button in _buttonsArray) + for (NSUInteger i=0; i<_buttonsArray.count; i++) { + LGPlusButton *button = _buttonsArray[i]; + WrapperView *buttonWrapperView = _buttonWrapperViewsArray1[i]; + + // don't process event if button is hidden. + if (buttonWrapperView.alpha == 0.) { + continue; + } + CGPoint newPoint = [self convertPoint:point toView:button]; view = [button hitTest:newPoint withEvent:event]; From 7663bc57862b100c7275dd8e43a5b6a2dbfb6022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Fe=CC=81vrier?= Date: Wed, 14 Dec 2016 15:22:58 +0100 Subject: [PATCH 2/8] Fix KVO crash Fix crash due to the KVO when we remove the superview instance, and create a new instance --- LGPlusButtonsView/LGPlusButtonsView.m | 109 +++++++++----------------- 1 file changed, 37 insertions(+), 72 deletions(-) diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index 2f76fc2..b75b0f0 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -72,9 +72,6 @@ typedef NS_ENUM(NSUInteger, LGPlusButtonDescriptionsPosition) LGPlusButtonDescriptionsPositionRight = 1 }; -@property (assign, nonatomic, getter=isObserversAdded) BOOL observersAdded; -@property (assign, nonatomic, getter=isObserversForScrollViewAdded) BOOL observersForScrollViewAdded; - @property (assign, nonatomic) LGPlusButtonDescriptionsPosition descriptionsPosition; @property (assign, nonatomic) UIView *parentView; @@ -300,6 +297,9 @@ + (instancetype)plusButtonsViewWithNumberOfButtons:(NSUInteger)numberOfButtons - (void)dealloc { + [self removeObservers:self.superview]; + [self setObservedScrollView:nil]; + #if DEBUG NSLog(@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__); #endif @@ -336,10 +336,8 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event - (void)willMoveToSuperview:(UIView *)newSuperview { [self removeObservers:self.superview]; - - if (newSuperview) - [self addObservers:newSuperview]; - + [self addObservers:newSuperview]; + [super willMoveToSuperview:newSuperview]; } @@ -1907,58 +1905,42 @@ - (void)deselectPlusButtonViewWithAnimationType:(LGPlusButtonAnimationType)type - (void)addObservers:(UIView *)view { - if (!self.isObserversAdded && view) - { - _observersAdded = YES; - - [view addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil]; - - if ([view isKindOfClass:[UIScrollView class]]) - { - [view addObserver:self forKeyPath:@"contentInset" options:NSKeyValueObservingOptionNew context:nil]; - [view addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; - [view addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil]; - } - - if (_observedScrollView) - { - NSAssert([_observedScrollView isKindOfClass:[UIScrollView class]], @"observedScrollView needs to have UIScrollView kind of class"); - - _observersForScrollViewAdded = YES; + if (!view) return; + + [view addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil]; + + if ([view isKindOfClass:[UIScrollView class]]) + [self setObservedScrollView:view]; +} - [_observedScrollView addObserver:self forKeyPath:@"contentInset" options:NSKeyValueObservingOptionNew context:nil]; - [_observedScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; - [_observedScrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil]; - } - } +- (void)addScrollViewObservers:(UIScrollView *)observedScrollView +{ + if (!observedScrollView) return; + + NSAssert([observedScrollView isKindOfClass:[UIScrollView class]], @"observedScrollView needs to have UIScrollView kind of class"); + + [observedScrollView addObserver:self forKeyPath:@"contentInset" options:NSKeyValueObservingOptionNew context:nil]; + [observedScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; + [observedScrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil]; } - (void)removeObservers:(UIView *)view { - if (self.isObserversAdded && view) - { - _observersAdded = NO; - - [view removeObserver:self forKeyPath:@"frame"]; - - if ([view isKindOfClass:[UIScrollView class]]) - { - [view removeObserver:self forKeyPath:@"contentInset"]; - [view removeObserver:self forKeyPath:@"contentOffset"]; - [view removeObserver:self forKeyPath:@"contentSize"]; - } - - if (self.isObserversForScrollViewAdded) - { - NSAssert([_observedScrollView isKindOfClass:[UIScrollView class]], @"observedScrollView needs to have UIScrollView kind of class"); - - _observersForScrollViewAdded = NO; + if (!view) return; + + [view removeObserver:self forKeyPath:@"frame"]; + + if (view == self.observedScrollView) + [self setObservedScrollView:nil]; +} - [_observedScrollView removeObserver:self forKeyPath:@"contentInset"]; - [_observedScrollView removeObserver:self forKeyPath:@"contentOffset"]; - [_observedScrollView removeObserver:self forKeyPath:@"contentSize"]; - } - } +- (void)removeScrollViewObservers:(UIScrollView *)observedScrollView +{ + if (!observedScrollView) return; + + [observedScrollView removeObserver:self forKeyPath:@"contentInset"]; + [observedScrollView removeObserver:self forKeyPath:@"contentOffset"]; + [observedScrollView removeObserver:self forKeyPath:@"contentSize"]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context @@ -2025,25 +2007,8 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N - (void)setObservedScrollView:(UIScrollView *)observedScrollView { - if (observedScrollView) - NSAssert([observedScrollView isKindOfClass:[UIScrollView class]], @"observedScrollView needs to have UIScrollView kind of class"); - - if (self.isObserversForScrollViewAdded) - { - [_observedScrollView removeObserver:self forKeyPath:@"contentInset"]; - [_observedScrollView removeObserver:self forKeyPath:@"contentOffset"]; - [_observedScrollView removeObserver:self forKeyPath:@"contentSize"]; - } - - if (observedScrollView) - { - _observersForScrollViewAdded = YES; - - [observedScrollView addObserver:self forKeyPath:@"contentInset" options:NSKeyValueObservingOptionNew context:nil]; - [observedScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; - [observedScrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil]; - } - else _observersForScrollViewAdded = NO; + [self removeScrollViewObservers:self.observedScrollView]; + [self addScrollViewObservers:observedScrollView]; _observedScrollView = observedScrollView; } From 6046fca9a9851a7cd33ba691a48080bf58c394ef Mon Sep 17 00:00:00 2001 From: AnatoliyPozdeyev Date: Thu, 29 Jun 2017 17:50:55 +0300 Subject: [PATCH 3/8] Updated podspec. --- LGPlusButtonsView.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LGPlusButtonsView.podspec b/LGPlusButtonsView.podspec index c92a2ca..01a58cf 100644 --- a/LGPlusButtonsView.podspec +++ b/LGPlusButtonsView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGPlusButtonsView' - s.version = '1.1.1' + s.version = '1.1.2' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGPlusButtonsView' From d0434d9f523b5d768430fa38d046bb96f277ddbf Mon Sep 17 00:00:00 2001 From: AnatoliyPozdeyev Date: Fri, 5 Jan 2018 16:43:12 +0300 Subject: [PATCH 4/8] New delegate's method for button touch down action. Version 1.1.3. --- LGPlusButtonsView.podspec | 2 +- LGPlusButtonsView/LGPlusButtonsView.h | 1 + LGPlusButtonsView/LGPlusButtonsView.m | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/LGPlusButtonsView.podspec b/LGPlusButtonsView.podspec index 01a58cf..d124514 100644 --- a/LGPlusButtonsView.podspec +++ b/LGPlusButtonsView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGPlusButtonsView' - s.version = '1.1.2' + s.version = '1.1.3' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGPlusButtonsView' diff --git a/LGPlusButtonsView/LGPlusButtonsView.h b/LGPlusButtonsView/LGPlusButtonsView.h index 61521c6..6d5bf5f 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.h +++ b/LGPlusButtonsView/LGPlusButtonsView.h @@ -55,6 +55,7 @@ static NSString *const kLGPlusButtonsViewActionNotification = @"kLGPlus - (void)plusButtonsViewDidShowButtons:(LGPlusButtonsView *)plusButtonsView; - (void)plusButtonsViewDidHideButtons:(LGPlusButtonsView *)plusButtonsView; - (void)plusButtonsView:(LGPlusButtonsView *)plusButtonsView buttonPressedWithTitle:(NSString *)title description:(NSString *)description index:(NSUInteger)index; +- (void)plusButtonsView:(LGPlusButtonsView *)plusButtonsView buttonTouchDownWithTitle:(NSString *)title description:(NSString *)description index:(NSUInteger)index; @end diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index 32ac392..af27ccf 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -187,6 +187,7 @@ - (instancetype)initWithNumberOfButtons:(NSUInteger)numberOfButtons LGPlusButton *button = [LGPlusButton new]; button.tag = i; [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; + [button addTarget:self action:@selector(buttonTouchDownAction:) forControlEvents:UIControlEventTouchDown]; if (showAfterInit) button.showing = ((firstButtonIsPlusButton && i == 0) || !firstButtonIsPlusButton); [wrapperView2 addSubview:button]; @@ -1264,6 +1265,16 @@ - (void)tapGesture:(UITapGestureRecognizer *)gestureRecognizer [self hideAnimated:YES completionHandler:nil]; } +- (void)buttonTouchDownAction:(LGPlusButton *)button +{ + NSUInteger index = button.tag; + + LGPlusButtonDescription *description = _descriptionsArray[index]; + + if (_delegate && [_delegate respondsToSelector:@selector(plusButtonsView:buttonTouchDownWithTitle:description:index:)]) + [_delegate plusButtonsView:self buttonTouchDownWithTitle:button.titleLabel.text description:description.text index:button.tag]; +} + - (void)buttonAction:(LGPlusButton *)button { NSUInteger index = button.tag; From 05c950600f831a7a9e303b3aaa8ff2d384bbad67 Mon Sep 17 00:00:00 2001 From: AnatoliyPozdeyev Date: Mon, 2 Jul 2018 11:25:27 +0300 Subject: [PATCH 5/8] New method to get buttons frame. Version 1.1.4. --- .../PlusScrollViewController.m | 36 ++++++++++--------- LGPlusButtonsView.podspec | 2 +- LGPlusButtonsView/LGPlusButtonsView.h | 2 ++ LGPlusButtonsView/LGPlusButtonsView.m | 11 ++++++ 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m b/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m index f71646e..36c5b7c 100644 --- a/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m +++ b/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m @@ -48,8 +48,8 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - _plusButtonsViewMain = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:4 - firstButtonIsPlusButton:YES + _plusButtonsViewMain = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:1 + firstButtonIsPlusButton:NO showAfterInit:YES actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index) { @@ -60,15 +60,17 @@ - (void)viewWillAppear:(BOOL)animated }]; _plusButtonsViewMain.observedScrollView = self.scrollView; - _plusButtonsViewMain.coverColor = [UIColor colorWithWhite:1.f alpha:0.7]; + _plusButtonsViewMain.coverColor = [UIColor colorWithWhite:1.f alpha:0]; _plusButtonsViewMain.position = LGPlusButtonsViewPositionBottomRight; _plusButtonsViewMain.plusButtonAnimationType = LGPlusButtonAnimationTypeRotate; - [_plusButtonsViewMain setButtonsTitles:@[@"+", @"", @"", @""] forState:UIControlStateNormal]; - [_plusButtonsViewMain setDescriptionsTexts:@[@"", @"Take a photo", @"Choose from gallery", @"Send a message"]]; - [_plusButtonsViewMain setButtonsImages:@[[NSNull new], [UIImage imageNamed:@"Camera"], [UIImage imageNamed:@"Picture"], [UIImage imageNamed:@"Message"]] - forState:UIControlStateNormal - forOrientation:LGPlusButtonsViewOrientationAll]; + [_plusButtonsViewMain setButtonsTitles:@[@"+"] forState:UIControlStateNormal]; +// [_plusButtonsViewMain setButtonsTitles:@[@"+", @"", @"", @""] forState:UIControlStateNormal]; +// [_plusButtonsViewMain setDescriptionsTexts:@[@"", @"Take a photo", @"Choose from gallery", @"Send a message"]]; + [_plusButtonsViewMain setDescriptionsTexts:@[@""]]; +// [_plusButtonsViewMain setButtonsImages:@[[NSNull new], [UIImage imageNamed:@"Camera"], [UIImage imageNamed:@"Picture"], [UIImage imageNamed:@"Message"]] +// forState:UIControlStateNormal +// forOrientation:LGPlusButtonsViewOrientationAll]; [_plusButtonsViewMain setButtonsAdjustsImageWhenHighlighted:NO]; [_plusButtonsViewMain setButtonsBackgroundColor:[UIColor colorWithRed:0.f green:0.5 blue:1.f alpha:1.f] forState:UIControlStateNormal]; @@ -88,12 +90,12 @@ - (void)viewWillAppear:(BOOL)animated [_plusButtonsViewMain setButtonAtIndex:0 titleFont:[UIFont systemFontOfSize:40.f] forOrientation:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? LGPlusButtonsViewOrientationPortrait : LGPlusButtonsViewOrientationAll)]; [_plusButtonsViewMain setButtonAtIndex:0 titleOffset:CGPointMake(0.f, -3.f) forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.f blue:0.5 alpha:1.f] forState:UIControlStateNormal]; - [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted]; - [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.5 blue:0.f alpha:1.f] forState:UIControlStateNormal]; - [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.6 blue:0.2 alpha:1.f] forState:UIControlStateHighlighted]; - [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.7 blue:0.f alpha:1.f] forState:UIControlStateNormal]; - [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.8 blue:0.f alpha:1.f] forState:UIControlStateHighlighted]; +// [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.f blue:0.5 alpha:1.f] forState:UIControlStateNormal]; +// [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted]; +// [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.5 blue:0.f alpha:1.f] forState:UIControlStateNormal]; +// [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.6 blue:0.2 alpha:1.f] forState:UIControlStateHighlighted]; +// [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.7 blue:0.f alpha:1.f] forState:UIControlStateNormal]; +// [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.8 blue:0.f alpha:1.f] forState:UIControlStateHighlighted]; [_plusButtonsViewMain setDescriptionsBackgroundColor:[UIColor whiteColor]]; [_plusButtonsViewMain setDescriptionsTextColor:[UIColor blackColor]]; @@ -104,9 +106,9 @@ - (void)viewWillAppear:(BOOL)animated [_plusButtonsViewMain setDescriptionsLayerCornerRadius:6.f forOrientation:LGPlusButtonsViewOrientationAll]; [_plusButtonsViewMain setDescriptionsContentEdgeInsets:UIEdgeInsetsMake(4.f, 8.f, 4.f, 8.f) forOrientation:LGPlusButtonsViewOrientationAll]; - for (NSUInteger i=1; i<=3; i++) - [_plusButtonsViewMain setButtonAtIndex:i offset:CGPointMake(-6.f, 0.f) - forOrientation:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? LGPlusButtonsViewOrientationPortrait : LGPlusButtonsViewOrientationAll)]; +// for (NSUInteger i=1; i<=3; i++) +// [_plusButtonsViewMain setButtonAtIndex:i offset:CGPointMake(-6.f, 0.f) +// forOrientation:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? LGPlusButtonsViewOrientationPortrait : LGPlusButtonsViewOrientationAll)]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { diff --git a/LGPlusButtonsView.podspec b/LGPlusButtonsView.podspec index d124514..6d1896c 100644 --- a/LGPlusButtonsView.podspec +++ b/LGPlusButtonsView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGPlusButtonsView' - s.version = '1.1.3' + s.version = '1.1.4' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGPlusButtonsView' diff --git a/LGPlusButtonsView/LGPlusButtonsView.h b/LGPlusButtonsView/LGPlusButtonsView.h index 6d5bf5f..fbcae60 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.h +++ b/LGPlusButtonsView/LGPlusButtonsView.h @@ -151,6 +151,8 @@ typedef NS_ENUM(NSUInteger, LGPlusButtonAnimationType) #pragma mark - Buttons all +- (CGRect)buttonFrame:(NSUInteger)index; + - (void)setButtonsTitles:(NSArray *)titles forState:(UIControlState)state; - (void)setButtonsTitleColor:(UIColor *)titleColor forState:(UIControlState)state; - (void)setButtonsTitleColors:(NSArray *)titleColors forState:(UIControlState)state; diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index af27ccf..7ee3bff 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -383,6 +383,17 @@ - (UIEdgeInsets)contentEdgeInsetsForOrientation:(LGPlusButtonsViewOrientation)or #pragma mark Buttons all +- (CGRect)buttonFrame:(NSUInteger)index { + UIView *button = _buttonsArray[ index ]; + if (button == nil) { + NSAssert(NO, @"Unexpected button index: %@, buttons count: %@", @(index), @(_buttonsArray.count)); + return CGRectZero; + } + + CGRect frame = [self convertRect:button.bounds fromView:button]; + return frame; +} + - (void)setButtonsTitles:(NSArray *)titles forState:(UIControlState)state { NSAssert(_buttonsArray.count == titles.count, kLGPlusButtonsViewAssertionWarning(@"titles")); From 65b170d211628b89f4e4b89898691a5a90cbfc8e Mon Sep 17 00:00:00 2001 From: AnatoliyPozdeyev Date: Mon, 27 Aug 2018 20:32:16 +0300 Subject: [PATCH 6/8] Additional buttons type animation with sliding from first button and with bigger bouncing. Pod version 1.1.5. --- .../PlusScrollViewController.m | 184 +++++++++--------- LGPlusButtonsView.podspec | 2 +- LGPlusButtonsView/LGPlusButtonsView.h | 3 +- LGPlusButtonsView/LGPlusButtonsView.m | 125 ++++++++---- 4 files changed, 184 insertions(+), 130 deletions(-) diff --git a/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m b/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m index 36c5b7c..b2c7b1b 100644 --- a/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m +++ b/Demo/LGPlusButtonsViewDemo/PlusScrollViewController.m @@ -48,8 +48,8 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - _plusButtonsViewMain = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:1 - firstButtonIsPlusButton:NO + _plusButtonsViewMain = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:4 + firstButtonIsPlusButton:YES showAfterInit:YES actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index) { @@ -60,17 +60,17 @@ - (void)viewWillAppear:(BOOL)animated }]; _plusButtonsViewMain.observedScrollView = self.scrollView; - _plusButtonsViewMain.coverColor = [UIColor colorWithWhite:1.f alpha:0]; + _plusButtonsViewMain.coverColor = [UIColor colorWithWhite:1.f alpha:0.7]; _plusButtonsViewMain.position = LGPlusButtonsViewPositionBottomRight; _plusButtonsViewMain.plusButtonAnimationType = LGPlusButtonAnimationTypeRotate; + _plusButtonsViewMain.appearingAnimationType = LGPlusButtonsAppearingAnimationTypeCrossDissolveAndSlideVertical; + _plusButtonsViewMain.buttonsAppearingAnimationType = LGPlusButtonsAppearingAnimationTypeCrossDissolveAndFullySlideVertical; - [_plusButtonsViewMain setButtonsTitles:@[@"+"] forState:UIControlStateNormal]; -// [_plusButtonsViewMain setButtonsTitles:@[@"+", @"", @"", @""] forState:UIControlStateNormal]; -// [_plusButtonsViewMain setDescriptionsTexts:@[@"", @"Take a photo", @"Choose from gallery", @"Send a message"]]; - [_plusButtonsViewMain setDescriptionsTexts:@[@""]]; -// [_plusButtonsViewMain setButtonsImages:@[[NSNull new], [UIImage imageNamed:@"Camera"], [UIImage imageNamed:@"Picture"], [UIImage imageNamed:@"Message"]] -// forState:UIControlStateNormal -// forOrientation:LGPlusButtonsViewOrientationAll]; + [_plusButtonsViewMain setButtonsTitles:@[@"+", @"", @"", @""] forState:UIControlStateNormal]; + [_plusButtonsViewMain setDescriptionsTexts:@[@"", @"Take a photo", @"Choose from gallery", @"Send a message"]]; + [_plusButtonsViewMain setButtonsImages:@[[NSNull new], [UIImage imageNamed:@"Camera"], [UIImage imageNamed:@"Picture"], [UIImage imageNamed:@"Message"]] + forState:UIControlStateNormal + forOrientation:LGPlusButtonsViewOrientationAll]; [_plusButtonsViewMain setButtonsAdjustsImageWhenHighlighted:NO]; [_plusButtonsViewMain setButtonsBackgroundColor:[UIColor colorWithRed:0.f green:0.5 blue:1.f alpha:1.f] forState:UIControlStateNormal]; @@ -90,12 +90,12 @@ - (void)viewWillAppear:(BOOL)animated [_plusButtonsViewMain setButtonAtIndex:0 titleFont:[UIFont systemFontOfSize:40.f] forOrientation:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? LGPlusButtonsViewOrientationPortrait : LGPlusButtonsViewOrientationAll)]; [_plusButtonsViewMain setButtonAtIndex:0 titleOffset:CGPointMake(0.f, -3.f) forOrientation:LGPlusButtonsViewOrientationAll]; -// [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.f blue:0.5 alpha:1.f] forState:UIControlStateNormal]; -// [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted]; -// [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.5 blue:0.f alpha:1.f] forState:UIControlStateNormal]; -// [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.6 blue:0.2 alpha:1.f] forState:UIControlStateHighlighted]; -// [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.7 blue:0.f alpha:1.f] forState:UIControlStateNormal]; -// [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.8 blue:0.f alpha:1.f] forState:UIControlStateHighlighted]; + [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.f blue:0.5 alpha:1.f] forState:UIControlStateNormal]; + [_plusButtonsViewMain setButtonAtIndex:1 backgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted]; + [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.5 blue:0.f alpha:1.f] forState:UIControlStateNormal]; + [_plusButtonsViewMain setButtonAtIndex:2 backgroundColor:[UIColor colorWithRed:1.f green:0.6 blue:0.2 alpha:1.f] forState:UIControlStateHighlighted]; + [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.7 blue:0.f alpha:1.f] forState:UIControlStateNormal]; + [_plusButtonsViewMain setButtonAtIndex:3 backgroundColor:[UIColor colorWithRed:0.f green:0.8 blue:0.f alpha:1.f] forState:UIControlStateHighlighted]; [_plusButtonsViewMain setDescriptionsBackgroundColor:[UIColor whiteColor]]; [_plusButtonsViewMain setDescriptionsTextColor:[UIColor blackColor]]; @@ -106,9 +106,9 @@ - (void)viewWillAppear:(BOOL)animated [_plusButtonsViewMain setDescriptionsLayerCornerRadius:6.f forOrientation:LGPlusButtonsViewOrientationAll]; [_plusButtonsViewMain setDescriptionsContentEdgeInsets:UIEdgeInsetsMake(4.f, 8.f, 4.f, 8.f) forOrientation:LGPlusButtonsViewOrientationAll]; -// for (NSUInteger i=1; i<=3; i++) -// [_plusButtonsViewMain setButtonAtIndex:i offset:CGPointMake(-6.f, 0.f) -// forOrientation:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? LGPlusButtonsViewOrientationPortrait : LGPlusButtonsViewOrientationAll)]; + for (NSUInteger i=1; i<=3; i++) + [_plusButtonsViewMain setButtonAtIndex:i offset:CGPointMake(-6.f, 0.f) + forOrientation:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? LGPlusButtonsViewOrientationPortrait : LGPlusButtonsViewOrientationAll)]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { @@ -118,79 +118,79 @@ - (void)viewWillAppear:(BOOL)animated [self.navigationController.view addSubview:_plusButtonsViewMain]; - // ----- - - _plusButtonsViewNavBar = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:3 - firstButtonIsPlusButton:NO - showAfterInit:NO - actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index) - { - NSLog(@"actionHandler | title: %@, description: %@, index: %lu", title, description, (long unsigned)index); - }]; - - _plusButtonsViewNavBar.showHideOnScroll = NO; - _plusButtonsViewNavBar.appearingAnimationType = LGPlusButtonsAppearingAnimationTypeCrossDissolveAndPop; - _plusButtonsViewNavBar.position = LGPlusButtonsViewPositionTopRight; - - [_plusButtonsViewNavBar setButtonsTitles:@[@"1", @"2", @"3"] forState:UIControlStateNormal]; - [_plusButtonsViewNavBar setDescriptionsTexts:@[@"Description 1", @"Description 2", @"Description 3"]]; - - [_plusButtonsViewNavBar setButtonsTitleFont:[UIFont boldSystemFontOfSize:32.f] forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewNavBar setButtonsSize:CGSizeMake(52.f, 52.f) forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewNavBar setButtonsLayerCornerRadius:52.f/2.f forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewNavBar setButtonsBackgroundColor:[UIColor colorWithRed:0.f green:0.5 blue:1.f alpha:1.f] forState:UIControlStateNormal]; - [_plusButtonsViewNavBar setButtonsBackgroundColor:[UIColor colorWithRed:0.2 green:0.6 blue:1.f alpha:1.f] forState:UIControlStateHighlighted]; - [_plusButtonsViewNavBar setButtonsLayerShadowColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1.f]]; - [_plusButtonsViewNavBar setButtonsLayerShadowOpacity:0.5]; - [_plusButtonsViewNavBar setButtonsLayerShadowRadius:3.f]; - [_plusButtonsViewNavBar setButtonsLayerShadowOffset:CGSizeMake(0.f, 2.f)]; - - [_plusButtonsViewNavBar setDescriptionsTextColor:[UIColor whiteColor]]; - [_plusButtonsViewNavBar setDescriptionsBackgroundColor:[UIColor colorWithWhite:0.f alpha:0.66]]; - [_plusButtonsViewNavBar setDescriptionsLayerCornerRadius:6.f forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewNavBar setDescriptionsContentEdgeInsets:UIEdgeInsetsMake(4.f, 8.f, 4.f, 8.f) forOrientation:LGPlusButtonsViewOrientationAll]; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) - { - [_plusButtonsViewNavBar setButtonsSize:CGSizeMake(44.f, 44.f) forOrientation:LGPlusButtonsViewOrientationLandscape]; - [_plusButtonsViewNavBar setButtonsLayerCornerRadius:44.f/2.f forOrientation:LGPlusButtonsViewOrientationLandscape]; - [_plusButtonsViewNavBar setButtonsTitleFont:[UIFont systemFontOfSize:24.f] forOrientation:LGPlusButtonsViewOrientationLandscape]; - } - - [self.scrollView addSubview:_plusButtonsViewNavBar]; - - // ----- - - _plusButtonsViewExample = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:3 - firstButtonIsPlusButton:YES - showAfterInit:YES - actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index) - { - NSLog(@"actionHandler | title: %@, description: %@, index: %lu", title, description, (long unsigned)index); - }]; - - _plusButtonsViewExample.position = LGPlusButtonsViewPositionBottomLeft; - _plusButtonsViewExample.plusButtonAnimationType = LGPlusButtonAnimationTypeCrossDissolve; - _plusButtonsViewExample.buttonsAppearingAnimationType = LGPlusButtonsAppearingAnimationTypeCrossDissolve; - - [_plusButtonsViewExample setButtonsTitles:@[@"+", @"1", @"2"] forState:UIControlStateNormal]; - [_plusButtonsViewExample setDescriptionsTexts:@[@"", @"Description 1", @"Description 2"]]; - - [_plusButtonsViewExample setButtonsBackgroundColor:[UIColor colorWithRed:1.f green:0.f blue:0.5 alpha:1.f] forState:UIControlStateNormal]; - [_plusButtonsViewExample setButtonsBackgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted]; - [_plusButtonsViewExample setButtonsBackgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted|UIControlStateSelected]; - [_plusButtonsViewExample setButtonsSize:CGSizeMake(44.f, 44.f) forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewExample setButtonsLayerBorderWidth:2.f]; - [_plusButtonsViewExample setButtonsLayerBorderColor:[UIColor colorWithWhite:0.9 alpha:1.f]]; - [_plusButtonsViewExample setButtonsTitleFont:[UIFont systemFontOfSize:24.f] forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewExample setButtonAtIndex:0 titleOffset:CGPointMake(0.f, -2.f) forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewExample setButtonAtIndex:0 title:@"-" forState:UIControlStateSelected]; - - [_plusButtonsViewExample setDescriptionsTextColor:[UIColor whiteColor]]; - [_plusButtonsViewExample setDescriptionsFont:[UIFont boldSystemFontOfSize:18.f] forOrientation:LGPlusButtonsViewOrientationAll]; - [_plusButtonsViewExample setDescriptionsInsets:UIEdgeInsetsMake(0.f, 0.f, 0.f, 4.f) forOrientation:LGPlusButtonsViewOrientationAll]; - - [_exampleView addSubview:_plusButtonsViewExample]; +// // ----- +// +// _plusButtonsViewNavBar = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:3 +// firstButtonIsPlusButton:NO +// showAfterInit:NO +// actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index) +// { +// NSLog(@"actionHandler | title: %@, description: %@, index: %lu", title, description, (long unsigned)index); +// }]; +// +// _plusButtonsViewNavBar.showHideOnScroll = NO; +// _plusButtonsViewNavBar.appearingAnimationType = LGPlusButtonsAppearingAnimationTypeCrossDissolveAndPop; +// _plusButtonsViewNavBar.position = LGPlusButtonsViewPositionTopRight; +// +// [_plusButtonsViewNavBar setButtonsTitles:@[@"1", @"2", @"3"] forState:UIControlStateNormal]; +// [_plusButtonsViewNavBar setDescriptionsTexts:@[@"Description 1", @"Description 2", @"Description 3"]]; +// +// [_plusButtonsViewNavBar setButtonsTitleFont:[UIFont boldSystemFontOfSize:32.f] forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewNavBar setButtonsSize:CGSizeMake(52.f, 52.f) forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewNavBar setButtonsLayerCornerRadius:52.f/2.f forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewNavBar setButtonsBackgroundColor:[UIColor colorWithRed:0.f green:0.5 blue:1.f alpha:1.f] forState:UIControlStateNormal]; +// [_plusButtonsViewNavBar setButtonsBackgroundColor:[UIColor colorWithRed:0.2 green:0.6 blue:1.f alpha:1.f] forState:UIControlStateHighlighted]; +// [_plusButtonsViewNavBar setButtonsLayerShadowColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1.f]]; +// [_plusButtonsViewNavBar setButtonsLayerShadowOpacity:0.5]; +// [_plusButtonsViewNavBar setButtonsLayerShadowRadius:3.f]; +// [_plusButtonsViewNavBar setButtonsLayerShadowOffset:CGSizeMake(0.f, 2.f)]; +// +// [_plusButtonsViewNavBar setDescriptionsTextColor:[UIColor whiteColor]]; +// [_plusButtonsViewNavBar setDescriptionsBackgroundColor:[UIColor colorWithWhite:0.f alpha:0.66]]; +// [_plusButtonsViewNavBar setDescriptionsLayerCornerRadius:6.f forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewNavBar setDescriptionsContentEdgeInsets:UIEdgeInsetsMake(4.f, 8.f, 4.f, 8.f) forOrientation:LGPlusButtonsViewOrientationAll]; +// +// if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) +// { +// [_plusButtonsViewNavBar setButtonsSize:CGSizeMake(44.f, 44.f) forOrientation:LGPlusButtonsViewOrientationLandscape]; +// [_plusButtonsViewNavBar setButtonsLayerCornerRadius:44.f/2.f forOrientation:LGPlusButtonsViewOrientationLandscape]; +// [_plusButtonsViewNavBar setButtonsTitleFont:[UIFont systemFontOfSize:24.f] forOrientation:LGPlusButtonsViewOrientationLandscape]; +// } +// +// [self.scrollView addSubview:_plusButtonsViewNavBar]; +// +// // ----- +// +// _plusButtonsViewExample = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:3 +// firstButtonIsPlusButton:YES +// showAfterInit:YES +// actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index) +// { +// NSLog(@"actionHandler | title: %@, description: %@, index: %lu", title, description, (long unsigned)index); +// }]; +// +// _plusButtonsViewExample.position = LGPlusButtonsViewPositionBottomLeft; +// _plusButtonsViewExample.plusButtonAnimationType = LGPlusButtonAnimationTypeCrossDissolve; +// _plusButtonsViewExample.buttonsAppearingAnimationType = LGPlusButtonsAppearingAnimationTypeCrossDissolve; +// +// [_plusButtonsViewExample setButtonsTitles:@[@"+", @"1", @"2"] forState:UIControlStateNormal]; +// [_plusButtonsViewExample setDescriptionsTexts:@[@"", @"Description 1", @"Description 2"]]; +// +// [_plusButtonsViewExample setButtonsBackgroundColor:[UIColor colorWithRed:1.f green:0.f blue:0.5 alpha:1.f] forState:UIControlStateNormal]; +// [_plusButtonsViewExample setButtonsBackgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted]; +// [_plusButtonsViewExample setButtonsBackgroundColor:[UIColor colorWithRed:1.f green:0.2 blue:0.6 alpha:1.f] forState:UIControlStateHighlighted|UIControlStateSelected]; +// [_plusButtonsViewExample setButtonsSize:CGSizeMake(44.f, 44.f) forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewExample setButtonsLayerBorderWidth:2.f]; +// [_plusButtonsViewExample setButtonsLayerBorderColor:[UIColor colorWithWhite:0.9 alpha:1.f]]; +// [_plusButtonsViewExample setButtonsTitleFont:[UIFont systemFontOfSize:24.f] forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewExample setButtonAtIndex:0 titleOffset:CGPointMake(0.f, -2.f) forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewExample setButtonAtIndex:0 title:@"-" forState:UIControlStateSelected]; +// +// [_plusButtonsViewExample setDescriptionsTextColor:[UIColor whiteColor]]; +// [_plusButtonsViewExample setDescriptionsFont:[UIFont boldSystemFontOfSize:18.f] forOrientation:LGPlusButtonsViewOrientationAll]; +// [_plusButtonsViewExample setDescriptionsInsets:UIEdgeInsetsMake(0.f, 0.f, 0.f, 4.f) forOrientation:LGPlusButtonsViewOrientationAll]; +// +// [_exampleView addSubview:_plusButtonsViewExample]; } #pragma mark - Dealloc diff --git a/LGPlusButtonsView.podspec b/LGPlusButtonsView.podspec index 6d1896c..34af787 100644 --- a/LGPlusButtonsView.podspec +++ b/LGPlusButtonsView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGPlusButtonsView' - s.version = '1.1.4' + s.version = '1.1.5' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGPlusButtonsView' diff --git a/LGPlusButtonsView/LGPlusButtonsView.h b/LGPlusButtonsView/LGPlusButtonsView.h index fbcae60..4bf8ca1 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.h +++ b/LGPlusButtonsView/LGPlusButtonsView.h @@ -86,7 +86,8 @@ typedef NS_ENUM(NSUInteger, LGPlusButtonsAppearingAnimationType) LGPlusButtonsAppearingAnimationTypeCrossDissolve = 1, LGPlusButtonsAppearingAnimationTypeCrossDissolveAndSlideHorizontal = 2, LGPlusButtonsAppearingAnimationTypeCrossDissolveAndSlideVertical = 3, - LGPlusButtonsAppearingAnimationTypeCrossDissolveAndPop = 4 + LGPlusButtonsAppearingAnimationTypeCrossDissolveAndPop = 4, + LGPlusButtonsAppearingAnimationTypeCrossDissolveAndFullySlideVertical = 5 }; typedef NS_ENUM(NSUInteger, LGPlusButtonAnimationType) diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index 7ee3bff..1ce1166 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -1602,10 +1602,11 @@ - (void)showCoverViewAnimated:(BOOL)animated [LGPlusButtonsView animateStandardWithDuration:duration delay:0.f + animationType:type animations:^(void) - { - _coverView.alpha = 1.f; - } + { + _coverView.alpha = 1.f; + } completion:nil]; } } @@ -1635,26 +1636,41 @@ - (void)hideCoverViewAnimated:(BOOL)animated [LGPlusButtonsView animateStandardWithDuration:duration delay:0.f + animationType:type animations:^(void) - { - _coverView.alpha = 0.f; - } + { + _coverView.alpha = 0.f; + } completion:^(BOOL finished) - { - if (finished) - { - _coverView.hidden = YES; - - if ([self.superview isKindOfClass:[UIScrollView class]]) - [(UIScrollView *)self.superview setScrollEnabled:YES]; - } - }]; + { + if (finished) + { + _coverView.hidden = YES; + + if ([self.superview isKindOfClass:[UIScrollView class]]) + [(UIScrollView *)self.superview setScrollEnabled:YES]; + } + }]; } } } #pragma mark - Button Animations + +- (CGFloat)buttonStartOffset:(NSUInteger)index { + LGPlusButtonsViewOrientation orientation = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? LGPlusButtonsViewOrientationPortrait : LGPlusButtonsViewOrientationLandscape; + CGFloat offset = 0; + for (NSUInteger i = 0; i < index; i++) { + WrapperView *buttonWrapper = _buttonWrapperViewsArray1[i]; + LGPlusButton *button = _buttonsArray[i]; + UIEdgeInsets buttonInsets = [button insetsForOrientation:orientation]; + offset += buttonWrapper.frame.size.height + buttonInsets.top + buttonInsets.bottom; + } + return offset; +} + + - (void)showButtonAtIndex:(NSUInteger)index animationType:(LGPlusButtonsAppearingAnimationType)type delay:(NSTimeInterval)delay @@ -1677,10 +1693,17 @@ - (void)showButtonAtIndex:(NSUInteger)index if (scaleX && scaleY) transform = CGAffineTransformConcat(transform, CGAffineTransformMakeScale(scaleX, scaleY)); } + if (type == LGPlusButtonsAppearingAnimationTypeCrossDissolveAndFullySlideVertical) + { + CGFloat ty = [self buttonStartOffset:index]; + transform = CGAffineTransformConcat(transform, CGAffineTransformMakeTranslation([[(CALayer *)buttonWrapperView1.layer.presentationLayer valueForKeyPath:@"transform.translation.x"] floatValue], + ty)); + } else { transform = CGAffineTransformConcat(transform, CGAffineTransformMakeTranslation([[(CALayer *)buttonWrapperView1.layer.presentationLayer valueForKeyPath:@"transform.translation.x"] floatValue], [[(CALayer *)buttonWrapperView1.layer.presentationLayer valueForKeyPath:@"transform.translation.y"] floatValue])); + } buttonWrapperView1.alpha = [(CALayer *)buttonWrapperView1.layer.presentationLayer opacity]; @@ -1704,19 +1727,26 @@ - (void)showButtonAtIndex:(NSUInteger)index } else { - CGFloat dif = 1.f-buttonWrapperView1.alpha; - NSTimeInterval duration = animationSpeed*dif; - + CGFloat dif; + NSTimeInterval duration; + if (type == LGPlusButtonsAppearingAnimationTypeCrossDissolveAndFullySlideVertical) { + duration = (0.2 + index * 0.05); + delay = 0; + } else { + dif = 1.f-buttonWrapperView1.alpha; + duration = animationSpeed*dif; + } [LGPlusButtonsView animateStandardWithDuration:duration delay:delay + animationType:type animations:^(void) - { - [self showAnimationsWithButtonAtIndex:index]; - } + { + [self showAnimationsWithButtonAtIndex:index]; + } completion:^(BOOL finished) - { - if (completionHandler) completionHandler(finished); - }]; + { + if (completionHandler) completionHandler(finished); + }]; } } @@ -1788,9 +1818,15 @@ - (void)hideButtonAtIndex:(NSUInteger)index { if (animated) { - CGFloat dif = buttonWrapperView1.alpha-0.f; - NSTimeInterval duration = animationSpeed*dif*_hideAnimationCoef; - + CGFloat dif; + NSTimeInterval duration; + if (type == LGPlusButtonsAppearingAnimationTypeCrossDissolveAndFullySlideVertical) { + duration = 0.2 + index * 0.05; + delay = 0; + } else { + dif = buttonWrapperView1.alpha-0.f; + duration = animationSpeed*dif*_hideAnimationCoef; + } [UIView animateWithDuration:duration delay:delay options:0 @@ -1846,6 +1882,13 @@ - (void)hideAnimationsWithButtonAtIndex:(NSUInteger)index else transform = CGAffineTransformConcat(transform, CGAffineTransformMakeTranslation(0.f, -buttonWrapperView1.frame.size.height)); } + else if (type == LGPlusButtonsAppearingAnimationTypeCrossDissolveAndFullySlideVertical) { + CGFloat ty = [self buttonStartOffset:index]; + if (_position == LGPlusButtonsViewPositionTopLeft || _position == LGPlusButtonsViewPositionTopRight) { + ty = -ty; + } + transform = CGAffineTransformConcat(transform, CGAffineTransformMakeTranslation(0.f, ty)); + } else if (type == LGPlusButtonsAppearingAnimationTypeCrossDissolveAndPop) { transform = CGAffineTransformConcat(transform, CGAffineTransformMakeScale(0.5, 0.5)); @@ -2045,17 +2088,27 @@ - (void)setObservedScrollView:(UIScrollView *)observedScrollView #pragma mark - Support -+ (void)animateStandardWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay animations:(void(^)())animations completion:(void(^)(BOOL finished))completion ++ (void)animateStandardWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay animationType:(LGPlusButtonsAppearingAnimationType)type animations:(void(^)())animations completion:(void(^)(BOOL finished))completion { - if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) + if (@available(iOS 7.0, *)) { - [UIView animateWithDuration:duration - delay:delay - usingSpringWithDamping:1.f - initialSpringVelocity:0.5 - options:0 - animations:animations - completion:completion]; + if (type == LGPlusButtonsAppearingAnimationTypeCrossDissolveAndFullySlideVertical) { + [UIView animateWithDuration:duration + delay:0 + usingSpringWithDamping:0.6f + initialSpringVelocity:0. + options:0 + animations:animations + completion:completion]; + } else { + [UIView animateWithDuration:duration + delay:delay + usingSpringWithDamping:1.f + initialSpringVelocity:0.5 + options:0 + animations:animations + completion:completion]; + } } else { From b058dae3d8113e7ce659610291ba6b945715b809 Mon Sep 17 00:00:00 2001 From: AnatoliyPozdeyev Date: Tue, 28 Aug 2018 09:09:59 +0300 Subject: [PATCH 7/8] FAB is collapsed by outside swipe gesture. Pod version 1.1.6. --- LGPlusButtonsView.podspec | 2 +- LGPlusButtonsView/LGPlusButtonsView.m | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/LGPlusButtonsView.podspec b/LGPlusButtonsView.podspec index 34af787..48212ec 100644 --- a/LGPlusButtonsView.podspec +++ b/LGPlusButtonsView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGPlusButtonsView' - s.version = '1.1.5' + s.version = '1.1.6' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGPlusButtonsView' diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index 1ce1166..67f92d6 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -155,6 +155,22 @@ - (instancetype)initWithNumberOfButtons:(NSUInteger)numberOfButtons UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)]; [_coverView addGestureRecognizer:tapGesture]; + + UISwipeGestureRecognizer *slideRightGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)]; + slideRightGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight; + [_coverView addGestureRecognizer:slideRightGestureRecognizer]; + + UISwipeGestureRecognizer *slideLeftGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)]; + slideLeftGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft; + [_coverView addGestureRecognizer:slideLeftGestureRecognizer]; + + UISwipeGestureRecognizer *slideUpGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)]; + slideUpGestureRecognizer.direction = UISwipeGestureRecognizerDirectionUp; + [_coverView addGestureRecognizer:slideUpGestureRecognizer]; + + UISwipeGestureRecognizer *slideDownGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)]; + slideDownGestureRecognizer.direction = UISwipeGestureRecognizerDirectionDown; + [_coverView addGestureRecognizer:slideDownGestureRecognizer]; // ----- From 050287a2179e12bb6838aace0ec54752a89773ab Mon Sep 17 00:00:00 2001 From: AnatoliyPozdeyev Date: Thu, 22 Nov 2018 10:55:56 +0300 Subject: [PATCH 8/8] Make property isShowHideOnScroll read-write. Pod version 1.1.7. --- LGPlusButtonsView.podspec | 2 +- LGPlusButtonsView/LGPlusButtonsView.h | 2 +- LGPlusButtonsView/LGPlusButtonsView.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LGPlusButtonsView.podspec b/LGPlusButtonsView.podspec index 48212ec..f3ecb7d 100644 --- a/LGPlusButtonsView.podspec +++ b/LGPlusButtonsView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LGPlusButtonsView' - s.version = '1.1.6' + s.version = '1.1.7' s.platform = :ios, '6.0' s.license = 'MIT' s.homepage = 'https://github.com/Friend-LGA/LGPlusButtonsView' diff --git a/LGPlusButtonsView/LGPlusButtonsView.h b/LGPlusButtonsView/LGPlusButtonsView.h index 4bf8ca1..39839ca 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.h +++ b/LGPlusButtonsView/LGPlusButtonsView.h @@ -99,7 +99,7 @@ typedef NS_ENUM(NSUInteger, LGPlusButtonAnimationType) @property (assign, nonatomic, readonly, getter=isShowing) BOOL showing; @property (assign, nonatomic, readonly, getter=isButtonsShowing) BOOL buttonsShowing; -@property (assign, nonatomic, getter=isShowHideOnScroll) BOOL showHideOnScroll; +@property (assign, nonatomic) BOOL isShowHideOnScroll; /** Hide additional buttons on scroll. Default is NO */ @property (assign, nonatomic, getter=isHideButtonsOnScroll) BOOL hideButtonsOnScroll; /** Default is YES */ diff --git a/LGPlusButtonsView/LGPlusButtonsView.m b/LGPlusButtonsView/LGPlusButtonsView.m index 67f92d6..7c12e67 100644 --- a/LGPlusButtonsView/LGPlusButtonsView.m +++ b/LGPlusButtonsView/LGPlusButtonsView.m @@ -116,7 +116,7 @@ - (instancetype)initWithNumberOfButtons:(NSUInteger)numberOfButtons _appearingAnimationSpeed = 0.3; _buttonsAppearingAnimationSpeed = 0.3; _hideAnimationCoef = 0.66; - _showHideOnScroll = YES; + self.isShowHideOnScroll = YES; _disableShowHideOnScrollIfContentSizeLessThenFrame = YES; // -----