8000 Revert "Several changes" · KittenYang/KYGooeyMenu@356f000 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Revert "Several changes"
Browse files Browse the repository at this point in the history
  • Loading branch information
KittenYang committed Jul 9, 2015
1 parent da62bd5 commit 356f000
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 38 deletions.
6 changes: 3 additions & 3 deletions Classes/KYGooeyMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#import <UIKit/UIKit.h>


@protocol KYGooeyMenuDelegate <NSObject>
@protocol menuDidSelectedDelegate <NSObject>

-(void)didSelectMenuItem:(NSUInteger)index;
-(void)menuDidSelected:(int)index;

@end

Expand Down Expand Up @@ -41,5 +41,5 @@

-(id)initWithOrigin:(CGPoint)origin andDiameter:(CGFloat)diameter andDelegate:(UIViewController *)controller themeColor:(UIColor *)themeColor;

@property(nonatomic,weak)id<KYGooeyMenuDelegate> menuDelegate;
@property(nonatomic,weak)id<menuDidSelectedDelegate> menuDelegate;
@end
26 changes: 12 additions & 14 deletions Classes/KYGooeyMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ -(void)setUpSomeDatas{
//子视图离开主视图的距离 [distance]
distance = R + r + self.extraDistance;
//平分之后的角度,弧度制,因为sinf、cosf需要弧度制
CGFloat degreeComp = (180 - 180/(menuCount+1))*(M_PI/180);
CGFloat degree = (180/(menuCount+1))*(M_PI/180);


//参考点的坐标
CGPoint originPoint = self.mainView.center;
for (int i = 0; i < menuCount; i++) {
CGFloat cosDegree = cosf(degreeComp * (i+1));
CGFloat cosDegree = cosf(degree * (i+1));
CGFloat sinDegree = sinf(degree * (i+1));

CGPoint center = CGPointMake(originPoint.x + distance*cosDegree, originPoint.y - distance*sinDegree);
Expand All @@ -120,12 +120,10 @@ -(void)setUpSomeDatas{

//设置每个item的图片
CGFloat imageWidth = (item.frame.size.width / 2) *sin(M_PI_4) * 2;
if (self.menuImagesArray && [self.menuImagesArray count] > 0) {
UIImageView *menuImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, imageWidth, imageWidth)];
menuImage.center = CGPointMake(item.frame.size.width/2, item.frame.size.height/2);
menuImage.image = self.menuImagesArray[i];
[item addSubview:menuImage];
}
UIImageView *menuImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, imageWidth, imageWidth)];
menuImage.center = CGPointMake(item.frame.size.width/2, item.frame.size.height/2);
menuImage.image = self.menuImagesArray[i];
[item addSubview:menuImage];

UITapGestureRecognizer *menuTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(menuTap:)];
[item addGestureRecognizer:menuTap];
Expand Down Expand Up @@ -213,9 +211,11 @@ - (CGPathRef) getLeftLinePathWithAmount:(CGFloat)amount {

#pragma mark -- 点击菜单
-(void)menuTap:(UITapGestureRecognizer *)tapGes{

if ([self.menuDelegate respondsToSelector:@selector(didSelectMenuItem:)]) {
[self.menuDelegate didSelectMenuItem:tapGes.view.tag - 1];

for (int i = 0; i<menuCount; i++) {
if ((tapGes.view.tag == i+1) && [self.menuDelegate respondsToSelector:@selector(menuDidSelected:)]) {
[self.menuDelegate menuDidSelected:i+1];
}
}

[self tapToSwitchOpenOrClose];
Expand All @@ -227,9 +227,7 @@ -(void)tapToSwitchOpenOrClose{

if (!once) {
[self setUpSomeDatas];
if (self.menuImagesArray && [self.menuImagesArray count] > 0) {
NSAssert(self.menuImagesArray.count == menuCount, @"Images' count is not equal with menus' count");
}
NSAssert(self.menuImagesArray.count == menuCount, @"Images' count is not equal with menus' count");
once = YES;
}

Expand Down
21 changes: 0 additions & 21 deletions KYGooeyMenu/.gitignore

This file was deleted.

0 comments on commit 356f000

Please sign in to comment.
0