Skip to content

Commit

Permalink
Merge pull request #33 from thundertrick/master
Browse files Browse the repository at this point in the history
Add blooming from center
  • Loading branch information
Tangdixi committed Sep 6, 2015
2 parents 6c5ae08 + b86424e commit e1acb5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions DCPathButton/Classes/DCPathButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) {
kDCPathButtonBloomDirectionBottomRight = 6,
kDCPathButtonBloomDirectionRight = 7,
kDCPathButtonBloomDirectionTopRight = 8,
kDCPathButtonBloomDirectionCenter = 9,

};

Expand Down
15 changes: 15 additions & 0 deletions DCPathButton/Classes/DCPathButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -453,6 +461,10 @@ - (void)setBloomDirection:(kDCPathButtonBloomDirection)bloomDirection {

}

if (bloomDirection == kDCPathButtonBloomDirectionCenter) {
_bloomAngel = 360.0f;
}

}

- (void)pathCenterButtonBloom {
Expand Down Expand Up @@ -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++) {
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -153,6 +153,7 @@ typedef NS_ENUM(NSUInteger, kDCPathButtonBloomDirection) {
kDCPathButtonBloomDirectionBottomRight = 6,
kDCPathButtonBloomDirectionRight = 7,
kDCPathButtonBloomDirectionTopRight = 8,
kDCPathButtonBloomDirectionCenter = 9,

};
```
Expand Down

0 comments on commit e1acb5e

Please sign in to comment.