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++) { 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, }; ```