iOS开源项目:AwesomeMenu

https://github.com/levey/AwesomeMenu

模仿Path的menu,使用CoreAnimation实现.

iOS开源项目:AwesomeMenu

 

1、首先说使用

   AwesomeMenuItem *starMenuItem1 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage

                                                           highlightedImage:storyMenuItemImagePressed

                                                               ContentImage:starImage

                                                    highlightedContentImage:nil];

    AwesomeMenuItem *starMenuItem2 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage

                                                           highlightedImage:storyMenuItemImagePressed

                                                               ContentImage:starImage

                                                    highlightedContentImage:nil];

    AwesomeMenuItem *starMenuItem3 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage

                                                           highlightedImage:storyMenuItemImagePressed

                                                               ContentImage:starImage

                                                    highlightedContentImage:nil];

    AwesomeMenuItem *starMenuItem4 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage

                                                           highlightedImage:storyMenuItemImagePressed

                                                               ContentImage:starImage

                                                    highlightedContentImage:nil];

    AwesomeMenuItem *starMenuItem5 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage

                                                           highlightedImage:storyMenuItemImagePressed

                                                               ContentImage:starImage

                                                    highlightedContentImage:nil];

     

    NSArray *menus = [NSArray arrayWithObjects:starMenuItem1, starMenuItem2, starMenuItem3, starMenuItem4, starMenuItem5, nil];

    

    AwesomeMenuItem *startItem = [[AwesomeMenuItem alloc] initWithImage:[UIImage imageNamed:@"bg-addbutton.png"]

                                                       highlightedImage:[UIImage imageNamed:@"bg-addbutton-highlighted.png"]

                                                           ContentImage:[UIImage imageNamed:@"icon-plus.png"]

                                                highlightedContentImage:[UIImage imageNamed:@"icon-plus-highlighted.png"]];

    

    AwesomeMenu *menu = [[AwesomeMenu alloc] initWithFrame:self.window.bounds startItem:startItem optionMenus:menus];    

    menu.delegate = self;

    

    menu.menuWholeAngle = M_PI_2;

    menu.farRadius = 110.0f;

    menu.endRadius = 100.0f;

    menu.nearRadius = 90.0f;

    menu.animationDuration = 0.3f;

    menu.startPoint = CGPointMake(50.0, 410.0);

2、实现原理:

当点击中间的按钮后,

touchesBegan

touchesMoved

touchesEnded

会依次被调用。

在touchesBegan中,调用了,AwesomeMenu的AwesomeMenuItemTouchesBegan方法,这里会调用setExpanding方法,这里用了一个NSTimer来启动动画。

_expand和才close分别是打开和关闭的动画。

这里面的动画列子挺好的,这里就不多介绍了。

你可能感兴趣的:(menu)