注册

iOS - Path menu 的动画效果

AwesomeMenu 是一个与Path的故事菜单外观相同的菜单

通过设置菜单项来创建菜单:

UIImage *storyMenuItemImage = [UIImage imageNamed:@"bg-menuitem.png"];
UIImage *storyMenuItemImagePressed = [UIImage imageNamed:@"bg-menuitem-highlighted.png"];
UIImage *starImage = [UIImage imageNamed:@"icon-star.png"];
AwesomeMenuItem *starMenuItem1 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedContentImage:nil];
AwesomeMenuItem *starMenuItem2 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedContentImage:nil];
// the start item, similar to "add" button of Path
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:[NSArray arrayWithObjects:starMenuItem1, starMenuItem2]];
menu.delegate = self;
[self.window addSubview:menu];

您还可以使用菜单选项:

找到“添加”按钮的中心:

menu.startPoint = CGPointMake(160.0, 240.0);

设置旋转角度:

menu.rotateAngle = 0.0;

设置整个菜单角度:

menu.menuWholeAngle = M_PI * 2;

设置每个菜单飞出动画的延迟:

menu.timeOffset = 0.036f;

调整弹跳动画:

menu.farRadius = 140.0f;
menu.nearRadius = 110.0f;

设置“添加”按钮和菜单项之间的距离:

menu.endRadius = 120.0f;


常见问题及demo下载:https://github.com/levey/AwesomeMenu

源码下载:AwesomeMenu-master.zip

0 个评论

要回复文章请先登录注册