Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blooming from center #33

Merged
merged 4 commits into from
Sep 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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