From 287a6f41facf42da6438f0a4c3b9382e05cbbedb Mon Sep 17 00:00:00 2001 From: Xuyang Hu Date: Sat, 5 Sep 2015 02:08:58 +0800 Subject: [PATCH 1/4] Add blooming from center change related methods and examples (both OC and Swift). --- DCPathButton/Classes/DCPathButton.h | 2 +- DCPathButton/Classes/DCPathButton.m | 26 +++++++++++++++---- .../DCPathButton/Classes/DCPathButton.h | 1 + .../DCPathButton/Classes/DCPathButton.m | 26 +++++++++++++++---- .../Example-Swift/ViewController.swift | 4 ++- Example/Example/ViewController.m | 9 ++++--- .../DCPathButton/Classes/DCPathButton.h | 2 +- .../DCPathButton/Classes/DCPathButton.m | 18 ++++++++++++- 8 files changed, 71 insertions(+), 17 deletions(-) diff --git a/DCPathButton/Classes/DCPathButton.h b/DCPathButton/Classes/DCPathButton.h index cddfaf6..6d82c1d 100644 --- a/DCPathButton/Classes/DCPathButton.h +++ b/DCPathButton/Classes/DCPathButton.h @@ -24,7 +24,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, - + kDCPathButtonBloomDirectionCenter = 9, }; @protocol DCPathButtonDelegate diff --git a/DCPathButton/Classes/DCPathButton.m b/DCPathButton/Classes/DCPathButton.m index 0f0d08d..3ce7c48 100644 --- a/DCPathButton/Classes/DCPathButton.m +++ b/DCPathButton/Classes/DCPathButton.m @@ -46,7 +46,7 @@ - (instancetype)initWithCenterImage:(UIImage *)centerImage highlightedImage:(UIImage *)centerHighlightedImage { return [self initWithButtonFrame:CGRectZero centerImage:centerImage - highlightedImage:centerHighlightedImage]; + highlightedImage:centerHighlightedImage]; } - (instancetype)initWithButtonFrame:(CGRect)centerButtonFrame @@ -181,7 +181,7 @@ - (void)configureSounds { // Configure bloom sound // NSURL *bloomSoundURL = [NSURL fileURLWithPath:self.bloomSoundPath]; - + // Configure fold sound // NSURL *foldSoundURL = [NSURL fileURLWithPath:self.foldSoundPath]; @@ -273,6 +273,7 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1) * M_PI) * itemExpandRadius); + case kDCPathButtonBloomDirectionBottomLeft: return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 0.25) * M_PI) * itemExpandRadius, @@ -307,7 +308,12 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1.25) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1.25) * M_PI) * itemExpandRadius); - + + case kDCPathButtonBloomDirectionCenter: + + return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf(angel * 2 * M_PI) * itemExpandRadius, + self.pathCenterButtonBloomCenter.y + sinf(angel * 2 * M_PI) * itemExpandRadius); + default: NSAssert(self.bloomDirection, @"DCPathButtonError: An error occur when you configuring the bloom direction"); @@ -334,6 +340,9 @@ - (void)pathCenterButtonFold { } CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; // Load item buttons from array @@ -453,6 +462,10 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection { } + if (bloomDirection == kDCPathButtonBloomDirectionCenter) { + _bloomAngel = 360.0f; + } + } - (void)pathCenterButtonBloom { @@ -506,6 +519,9 @@ - (void)pathCenterButtonBloom { // 5. Excute the bloom animation // CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; for (int i = 0; i < self.itemButtons.count; i++) { @@ -531,8 +547,8 @@ - (void)pathCenterButtonBloom { CGPoint nearPoint = [self createEndPointWithRadius:self.bloomRadius - 5.0f andAngel:currentAngel/180.0f]; CAAnimationGroup *bloomAnimation = [self bloomAnimationWithEndPoint:endPoint - andFarPoint:farPoint - andNearPoint:nearPoint]; + andFarPoint:farPoint + andNearPoint:nearPoint]; [pathItemButton.layer addAnimation:bloomAnimation forKey:@"bloomAnimation"]; diff --git a/Example-Swift/DCPathButton/Classes/DCPathButton.h b/Example-Swift/DCPathButton/Classes/DCPathButton.h index cddfaf6..80a3017 100644 --- a/Example-Swift/DCPathButton/Classes/DCPathButton.h +++ b/Example-Swift/DCPathButton/Classes/DCPathButton.h @@ -24,6 +24,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, + kDCPathButtonBloomDirectionCenter = 9, }; diff --git a/Example-Swift/DCPathButton/Classes/DCPathButton.m b/Example-Swift/DCPathButton/Classes/DCPathButton.m index 0f0d08d..3ce7c48 100644 --- a/Example-Swift/DCPathButton/Classes/DCPathButton.m +++ b/Example-Swift/DCPathButton/Classes/DCPathButton.m @@ -46,7 +46,7 @@ - (instancetype)initWithCenterImage:(UIImage *)centerImage highlightedImage:(UIImage *)centerHighlightedImage { return [self initWithButtonFrame:CGRectZero centerImage:centerImage - highlightedImage:centerHighlightedImage]; + highlightedImage:centerHighlightedImage]; } - (instancetype)initWithButtonFrame:(CGRect)centerButtonFrame @@ -181,7 +181,7 @@ - (void)configureSounds { // Configure bloom sound // NSURL *bloomSoundURL = [NSURL fileURLWithPath:self.bloomSoundPath]; - + // Configure fold sound // NSURL *foldSoundURL = [NSURL fileURLWithPath:self.foldSoundPath]; @@ -273,6 +273,7 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1) * M_PI) * itemExpandRadius); + case kDCPathButtonBloomDirectionBottomLeft: return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 0.25) * M_PI) * itemExpandRadius, @@ -307,7 +308,12 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1.25) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1.25) * M_PI) * itemExpandRadius); - + + case kDCPathButtonBloomDirectionCenter: + + return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf(angel * 2 * M_PI) * itemExpandRadius, + self.pathCenterButtonBloomCenter.y + sinf(angel * 2 * M_PI) * itemExpandRadius); + default: NSAssert(self.bloomDirection, @"DCPathButtonError: An error occur when you configuring the bloom direction"); @@ -334,6 +340,9 @@ - (void)pathCenterButtonFold { } CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; // Load item buttons from array @@ -453,6 +462,10 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection { } + if (bloomDirection == kDCPathButtonBloomDirectionCenter) { + _bloomAngel = 360.0f; + } + } - (void)pathCenterButtonBloom { @@ -506,6 +519,9 @@ - (void)pathCenterButtonBloom { // 5. Excute the bloom animation // CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; for (int i = 0; i < self.itemButtons.count; i++) { @@ -531,8 +547,8 @@ - (void)pathCenterButtonBloom { CGPoint nearPoint = [self createEndPointWithRadius:self.bloomRadius - 5.0f andAngel:currentAngel/180.0f]; CAAnimationGroup *bloomAnimation = [self bloomAnimationWithEndPoint:endPoint - andFarPoint:farPoint - andNearPoint:nearPoint]; + andFarPoint:farPoint + andNearPoint:nearPoint]; [pathItemButton.layer addAnimation:bloomAnimation forKey:@"bloomAnimation"]; diff --git a/Example-Swift/Example-Swift/ViewController.swift b/Example-Swift/Example-Swift/ViewController.swift index fac682d..4a29a89 100644 --- a/Example-Swift/Example-Swift/ViewController.swift +++ b/Example-Swift/Example-Swift/ViewController.swift @@ -29,7 +29,9 @@ class ViewController: UIViewController, DCPathButtonDelegate { dcPathButton = DCPathButton(centerImage: UIImage(named: "chooser-button-tab"), highlightedImage: UIImage(named: "chooser-button-tab-highlighted")) dcPathButton.delegate = self - dcPathButton.dcButtonCenter = CGPointMake(self.view.bounds.width/2, self.view.bounds.height - 25.5) + dcPathButton.dcButtonCenter = self.view.center + dcPathButton.bloomDirection = kDCPathButtonBloomDirection.DCPathButtonBloomDirectionCenter + dcPathButton.bottomViewColor = UIColor.grayColor() dcPathButton.allowSounds = true dcPathButton.allowCenterButtonRotation = true dcPathButton.bloomRadius = 105 diff --git a/Example/Example/ViewController.m b/Example/Example/ViewController.m index 924eb31..0a48534 100644 --- a/Example/Example/ViewController.m +++ b/Example/Example/ViewController.m @@ -71,9 +71,12 @@ - (void)configureDCPathButton // dcPathButton.bloomRadius = 120.0f; + + // Change the DCButton's center // - dcPathButton.dcButtonCenter = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height - 25.5f); + dcPathButton.dcButtonCenter = self.view.center; + dcPathButton.bloomDirection = kDCPathButtonBloomDirectionCenter; // Setting the DCButton appearance // @@ -82,8 +85,8 @@ - (void)configureDCPathButton dcPathButton.bottomViewColor = [UIColor grayColor]; - dcPathButton.bloomDirection = kDCPathButtonBloomDirectionTopRight; - dcPathButton.dcButtonCenter = CGPointMake(10 + dcPathButton.frame.size.width/2, self.view.frame.size.height - dcPathButton.frame.size.height/2 - 10); +// dcPathButton.bloomDirection = kDCPathButtonBloomDirectionTopRight; +// dcPathButton.dcButtonCenter = CGPointMake(10 + dcPathButton.frame.size.width/2, self.view.frame.size.height - dcPathButton.frame.size.height/2 - 10); [self.view addSubview:dcPathButton]; diff --git a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h index cddfaf6..6d82c1d 100644 --- a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h +++ b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h @@ -24,7 +24,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, - + kDCPathButtonBloomDirectionCenter = 9, }; @protocol DCPathButtonDelegate diff --git a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m index 0f0d08d..23a87c9 100644 --- a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m +++ b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m @@ -273,6 +273,7 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1) * M_PI) * itemExpandRadius); + case kDCPathButtonBloomDirectionBottomLeft: return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 0.25) * M_PI) * itemExpandRadius, @@ -307,7 +308,12 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1.25) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1.25) * M_PI) * itemExpandRadius); - + + case kDCPathButtonBloomDirectionCenter: + + return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf(angel * 2 * M_PI) * itemExpandRadius, + self.pathCenterButtonBloomCenter.y + sinf(angel * 2 * M_PI) * itemExpandRadius); + default: NSAssert(self.bloomDirection, @"DCPathButtonError: An error occur when you configuring the bloom direction"); @@ -334,6 +340,9 @@ - (void)pathCenterButtonFold { } CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; // Load item buttons from array @@ -453,6 +462,10 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection { } + if (bloomDirection == kDCPathButtonBloomDirectionCenter) { + _bloomAngel = 360.0f; + } + } - (void)pathCenterButtonBloom { @@ -506,6 +519,9 @@ - (void)pathCenterButtonBloom { // 5. Excute the bloom animation // CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; for (int i = 0; i < self.itemButtons.count; i++) { From d0c8f9a2f09fcfd6c1d21d90b5c7c794587d21a0 Mon Sep 17 00:00:00 2001 From: Xuyang Hu Date: Mon, 7 Sep 2015 00:01:20 +0800 Subject: [PATCH 2/4] Revert "Add blooming from center" This reverts commit 287a6f41facf42da6438f0a4c3b9382e05cbbedb. --- DCPathButton/Classes/DCPathButton.h | 2 +- DCPathButton/Classes/DCPathButton.m | 26 ++++--------------- .../DCPathButton/Classes/DCPathButton.h | 1 - .../DCPathButton/Classes/DCPathButton.m | 26 ++++--------------- .../Example-Swift/ViewController.swift | 4 +-- Example/Example/ViewController.m | 9 +++---- .../DCPathButton/Classes/DCPathButton.h | 2 +- .../DCPathButton/Classes/DCPathButton.m | 18 +------------ 8 files changed, 17 insertions(+), 71 deletions(-) diff --git a/DCPathButton/Classes/DCPathButton.h b/DCPathButton/Classes/DCPathButton.h index 6d82c1d..cddfaf6 100644 --- a/DCPathButton/Classes/DCPathButton.h +++ b/DCPathButton/Classes/DCPathButton.h @@ -24,7 +24,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, - kDCPathButtonBloomDirectionCenter = 9, + }; @protocol DCPathButtonDelegate diff --git a/DCPathButton/Classes/DCPathButton.m b/DCPathButton/Classes/DCPathButton.m index 3ce7c48..0f0d08d 100644 --- a/DCPathButton/Classes/DCPathButton.m +++ b/DCPathButton/Classes/DCPathButton.m @@ -46,7 +46,7 @@ - (instancetype)initWithCenterImage:(UIImage *)centerImage highlightedImage:(UIImage *)centerHighlightedImage { return [self initWithButtonFrame:CGRectZero centerImage:centerImage - highlightedImage:centerHighlightedImage]; + highlightedImage:centerHighlightedImage]; } - (instancetype)initWithButtonFrame:(CGRect)centerButtonFrame @@ -181,7 +181,7 @@ - (void)configureSounds { // Configure bloom sound // NSURL *bloomSoundURL = [NSURL fileURLWithPath:self.bloomSoundPath]; - + // Configure fold sound // NSURL *foldSoundURL = [NSURL fileURLWithPath:self.foldSoundPath]; @@ -273,7 +273,6 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1) * M_PI) * itemExpandRadius); - case kDCPathButtonBloomDirectionBottomLeft: return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 0.25) * M_PI) * itemExpandRadius, @@ -308,12 +307,7 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1.25) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1.25) * M_PI) * itemExpandRadius); - - case kDCPathButtonBloomDirectionCenter: - - return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf(angel * 2 * M_PI) * itemExpandRadius, - self.pathCenterButtonBloomCenter.y + sinf(angel * 2 * M_PI) * itemExpandRadius); - + default: NSAssert(self.bloomDirection, @"DCPathButtonError: An error occur when you configuring the bloom direction"); @@ -340,9 +334,6 @@ - (void)pathCenterButtonFold { } CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; - if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { - itemGapAngel = self.bloomAngel / self.itemButtons.count; - } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; // Load item buttons from array @@ -462,10 +453,6 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection { } - if (bloomDirection == kDCPathButtonBloomDirectionCenter) { - _bloomAngel = 360.0f; - } - } - (void)pathCenterButtonBloom { @@ -519,9 +506,6 @@ - (void)pathCenterButtonBloom { // 5. Excute the bloom animation // CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; - if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { - itemGapAngel = self.bloomAngel / self.itemButtons.count; - } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; for (int i = 0; i < self.itemButtons.count; i++) { @@ -547,8 +531,8 @@ - (void)pathCenterButtonBloom { CGPoint nearPoint = [self createEndPointWithRadius:self.bloomRadius - 5.0f andAngel:currentAngel/180.0f]; CAAnimationGroup *bloomAnimation = [self bloomAnimationWithEndPoint:endPoint - andFarPoint:farPoint - andNearPoint:nearPoint]; + andFarPoint:farPoint + andNearPoint:nearPoint]; [pathItemButton.layer addAnimation:bloomAnimation forKey:@"bloomAnimation"]; diff --git a/Example-Swift/DCPathButton/Classes/DCPathButton.h b/Example-Swift/DCPathButton/Classes/DCPathButton.h index 80a3017..cddfaf6 100644 --- a/Example-Swift/DCPathButton/Classes/DCPathButton.h +++ b/Example-Swift/DCPathButton/Classes/DCPathButton.h @@ -24,7 +24,6 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, - kDCPathButtonBloomDirectionCenter = 9, }; diff --git a/Example-Swift/DCPathButton/Classes/DCPathButton.m b/Example-Swift/DCPathButton/Classes/DCPathButton.m index 3ce7c48..0f0d08d 100644 --- a/Example-Swift/DCPathButton/Classes/DCPathButton.m +++ b/Example-Swift/DCPathButton/Classes/DCPathButton.m @@ -46,7 +46,7 @@ - (instancetype)initWithCenterImage:(UIImage *)centerImage highlightedImage:(UIImage *)centerHighlightedImage { return [self initWithButtonFrame:CGRectZero centerImage:centerImage - highlightedImage:centerHighlightedImage]; + highlightedImage:centerHighlightedImage]; } - (instancetype)initWithButtonFrame:(CGRect)centerButtonFrame @@ -181,7 +181,7 @@ - (void)configureSounds { // Configure bloom sound // NSURL *bloomSoundURL = [NSURL fileURLWithPath:self.bloomSoundPath]; - + // Configure fold sound // NSURL *foldSoundURL = [NSURL fileURLWithPath:self.foldSoundPath]; @@ -273,7 +273,6 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1) * M_PI) * itemExpandRadius); - case kDCPathButtonBloomDirectionBottomLeft: return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 0.25) * M_PI) * itemExpandRadius, @@ -308,12 +307,7 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1.25) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1.25) * M_PI) * itemExpandRadius); - - case kDCPathButtonBloomDirectionCenter: - - return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf(angel * 2 * M_PI) * itemExpandRadius, - self.pathCenterButtonBloomCenter.y + sinf(angel * 2 * M_PI) * itemExpandRadius); - + default: NSAssert(self.bloomDirection, @"DCPathButtonError: An error occur when you configuring the bloom direction"); @@ -340,9 +334,6 @@ - (void)pathCenterButtonFold { } CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; - if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { - itemGapAngel = self.bloomAngel / self.itemButtons.count; - } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; // Load item buttons from array @@ -462,10 +453,6 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection { } - if (bloomDirection == kDCPathButtonBloomDirectionCenter) { - _bloomAngel = 360.0f; - } - } - (void)pathCenterButtonBloom { @@ -519,9 +506,6 @@ - (void)pathCenterButtonBloom { // 5. Excute the bloom animation // CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; - if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { - itemGapAngel = self.bloomAngel / self.itemButtons.count; - } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; for (int i = 0; i < self.itemButtons.count; i++) { @@ -547,8 +531,8 @@ - (void)pathCenterButtonBloom { CGPoint nearPoint = [self createEndPointWithRadius:self.bloomRadius - 5.0f andAngel:currentAngel/180.0f]; CAAnimationGroup *bloomAnimation = [self bloomAnimationWithEndPoint:endPoint - andFarPoint:farPoint - andNearPoint:nearPoint]; + andFarPoint:farPoint + andNearPoint:nearPoint]; [pathItemButton.layer addAnimation:bloomAnimation forKey:@"bloomAnimation"]; diff --git a/Example-Swift/Example-Swift/ViewController.swift b/Example-Swift/Example-Swift/ViewController.swift index 4a29a89..fac682d 100644 --- a/Example-Swift/Example-Swift/ViewController.swift +++ b/Example-Swift/Example-Swift/ViewController.swift @@ -29,9 +29,7 @@ class ViewController: UIViewController, DCPathButtonDelegate { dcPathButton = DCPathButton(centerImage: UIImage(named: "chooser-button-tab"), highlightedImage: UIImage(named: "chooser-button-tab-highlighted")) dcPathButton.delegate = self - dcPathButton.dcButtonCenter = self.view.center - dcPathButton.bloomDirection = kDCPathButtonBloomDirection.DCPathButtonBloomDirectionCenter - dcPathButton.bottomViewColor = UIColor.grayColor() + dcPathButton.dcButtonCenter = CGPointMake(self.view.bounds.width/2, self.view.bounds.height - 25.5) dcPathButton.allowSounds = true dcPathButton.allowCenterButtonRotation = true dcPathButton.bloomRadius = 105 diff --git a/Example/Example/ViewController.m b/Example/Example/ViewController.m index 0a48534..924eb31 100644 --- a/Example/Example/ViewController.m +++ b/Example/Example/ViewController.m @@ -71,12 +71,9 @@ - (void)configureDCPathButton // dcPathButton.bloomRadius = 120.0f; - - // Change the DCButton's center // - dcPathButton.dcButtonCenter = self.view.center; - dcPathButton.bloomDirection = kDCPathButtonBloomDirectionCenter; + dcPathButton.dcButtonCenter = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height - 25.5f); // Setting the DCButton appearance // @@ -85,8 +82,8 @@ - (void)configureDCPathButton dcPathButton.bottomViewColor = [UIColor grayColor]; -// dcPathButton.bloomDirection = kDCPathButtonBloomDirectionTopRight; -// dcPathButton.dcButtonCenter = CGPointMake(10 + dcPathButton.frame.size.width/2, self.view.frame.size.height - dcPathButton.frame.size.height/2 - 10); + dcPathButton.bloomDirection = kDCPathButtonBloomDirectionTopRight; + dcPathButton.dcButtonCenter = CGPointMake(10 + dcPathButton.frame.size.width/2, self.view.frame.size.height - dcPathButton.frame.size.height/2 - 10); [self.view addSubview:dcPathButton]; diff --git a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h index 6d82c1d..cddfaf6 100644 --- a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h +++ b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.h @@ -24,7 +24,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, - kDCPathButtonBloomDirectionCenter = 9, + }; @protocol DCPathButtonDelegate diff --git a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m index 23a87c9..0f0d08d 100644 --- a/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m +++ b/Example/Pods/DCPathButton/DCPathButton/Classes/DCPathButton.m @@ -273,7 +273,6 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1) * M_PI) * itemExpandRadius); - case kDCPathButtonBloomDirectionBottomLeft: return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 0.25) * M_PI) * itemExpandRadius, @@ -308,12 +307,7 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1.25) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1.25) * M_PI) * itemExpandRadius); - - case kDCPathButtonBloomDirectionCenter: - - return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf(angel * 2 * M_PI) * itemExpandRadius, - self.pathCenterButtonBloomCenter.y + sinf(angel * 2 * M_PI) * itemExpandRadius); - + default: NSAssert(self.bloomDirection, @"DCPathButtonError: An error occur when you configuring the bloom direction"); @@ -340,9 +334,6 @@ - (void)pathCenterButtonFold { } CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; - if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { - itemGapAngel = self.bloomAngel / self.itemButtons.count; - } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; // Load item buttons from array @@ -462,10 +453,6 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection { } - if (bloomDirection == kDCPathButtonBloomDirectionCenter) { - _bloomAngel = 360.0f; - } - } - (void)pathCenterButtonBloom { @@ -519,9 +506,6 @@ - (void)pathCenterButtonBloom { // 5. Excute the bloom animation // CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; - if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { - itemGapAngel = self.bloomAngel / self.itemButtons.count; - } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; for (int i = 0; i < self.itemButtons.count; i++) { From 988ee165816e24fb1c04f05b8faf475812e184f9 Mon Sep 17 00:00:00 2001 From: Xuyang Hu Date: Mon, 7 Sep 2015 00:05:03 +0800 Subject: [PATCH 3/4] Add center blooming --- DCPathButton/Classes/DCPathButton.h | 1 + DCPathButton/Classes/DCPathButton.m | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/DCPathButton/Classes/DCPathButton.h b/DCPathButton/Classes/DCPathButton.h index cddfaf6..80a3017 100644 --- a/DCPathButton/Classes/DCPathButton.h +++ b/DCPathButton/Classes/DCPathButton.h @@ -24,6 +24,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, + kDCPathButtonBloomDirectionCenter = 9, }; diff --git a/DCPathButton/Classes/DCPathButton.m b/DCPathButton/Classes/DCPathButton.m index 0f0d08d..0667666 100644 --- a/DCPathButton/Classes/DCPathButton.m +++ b/DCPathButton/Classes/DCPathButton.m @@ -307,6 +307,11 @@ - (CGPoint)createEndPointWithRadius:(CGFloat)itemExpandRadius return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf((angel + 1.25) * M_PI) * itemExpandRadius, self.pathCenterButtonBloomCenter.y + sinf((angel + 1.25) * M_PI) * itemExpandRadius); + + case kDCPathButtonBloomDirectionCenter: + + return CGPointMake(self.pathCenterButtonBloomCenter.x + cosf(angel * 2 * M_PI) * itemExpandRadius, + self.pathCenterButtonBloomCenter.y + sinf(angel * 2 * M_PI) * itemExpandRadius); default: @@ -334,6 +339,9 @@ - (void)pathCenterButtonFold { } CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; // Load item buttons from array @@ -453,6 +461,10 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection { } + if (bloomDirection == kDCPathButtonBloomDirectionCenter) { + _bloomAngel = 360.0f; + } + } - (void)pathCenterButtonBloom { @@ -506,6 +518,9 @@ - (void)pathCenterButtonBloom { // 5. Excute the bloom animation // CGFloat itemGapAngel = self.bloomAngel / (self.itemButtons.count - 1) ; + if (self.bloomDirection == kDCPathButtonBloomDirectionCenter) { + itemGapAngel = self.bloomAngel / self.itemButtons.count; + } CGFloat currentAngel = (180.0f - self. bloomAngel)/2.0f; for (int i = 0; i < self.itemButtons.count; i++) { From b86424eda567c2075ce041427f0251bf52d13f25 Mon Sep 17 00:00:00 2001 From: Xuyang Hu Date: Mon, 7 Sep 2015 00:36:24 +0800 Subject: [PATCH 4/4] Add center blooming to document --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0f6fac..81f8e0f 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ self.bloomSoundPath = [[NSBundle mainBundle]pathForResource:@"bloom" ofType:@"ca ```objc @property (assign, nonatomic) kDCPathButtonBloomDirection bloomDirection; ``` -We have `8` directions in **DCPathButton**, use the `bloomDirection` property to change the direction. All the directions you can find in the `enum` below: +We have `9` directions in **DCPathButton**, use the `bloomDirection` property to change the direction. All the directions you can find in the `enum` below: ```objc typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { @@ -153,6 +153,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) { kDCPathButtonBloomDirectionBottomRight = 6, kDCPathButtonBloomDirectionRight = 7, kDCPathButtonBloomDirectionTopRight = 8, + kDCPathButtonBloomDirectionCenter = 9, }; ```