将AwesomeMenu与UITabBarController tabBar一起使用

时间:2014-04-15 16:35:03

标签: ios uitabbarcontroller uitabbar

我一直在玩我的UITabBar添加一个AwesomeMenu按钮。我的计划是将图标放在标签栏上方,看起来非常酷。我玩了一下,并且能够显示图标。我打电话给菜单,我只使用了我已经拥有的相同按钮,在标签栏后面添加了一个AwesomeMenu(所以图标从后面弹起)然后隐藏了Awesome菜单。我在标签栏的按钮上添加了一个动作,以模拟在精彩菜单上的点击,以及显示AwesomeMenu,然后完美地显示按钮。问题是,当我尝试点击这些按钮时,没有任何反应。我认为这是一个问题,因为它们位于UITabBar之上,但我无法确定。我在空白视图控制器的中间添加了一个普通的AwesomeMenu,其设置与我在标签栏上的设置相同(除了在标签栏上并被另一个按钮调用)并且它有效。当我按下按钮时,它们会起作用。基于此,我认为按钮显示在UITabBar上方或者可能只是按钮的工作方式存在问题。非常感谢任何帮助!

以下是我如何将按钮添加到UITabBar(非常标准):

UIImage *storyMenuItemImage = [UIImage imageNamed:@"Selector_Fill.png"];
    UIImage *scaledImage = [UIImage imageWithCGImage:[storyMenuItemImage CGImage] scale:(storyMenuItemImage.scale * 2.0) orientation:UIImageOrientationUp];

    UIImage *storyMenuItemImagePressed = [UIImage imageNamed:@"Selector_Fill.png"];

    UIImage *starImage = [UIImage imageNamed:@"Selector_Camera_Fill"];
    AwesomeMenuItem *starMenuItem1 = [[AwesomeMenuItem alloc] initWithImage:scaledImage
                                                           highlightedImage:storyMenuItemImagePressed
                                                               ContentImage:[UIImage imageNamed:@"Selector_Camera_Fill"]
                                                    highlightedContentImage:nil];
    AwesomeMenuItem *starMenuItem2 = [[AwesomeMenuItem alloc] initWithImage:scaledImage
                                                           highlightedImage:storyMenuItemImagePressed
                                                               ContentImage:[UIImage imageNamed:@"Selector_Video_Fill"]
                                                    highlightedContentImage:nil];


    AwesomeMenuItem *starMenuItem3 = [[AwesomeMenuItem alloc] initWithImage:scaledImage
                                                           highlightedImage:storyMenuItemImagePressed
                                                               ContentImage:[UIImage imageNamed:@"Selector_Pen"]
                                                    highlightedContentImage:nil];

    AwesomeMenuItem *starMenuItem4 = [[AwesomeMenuItem alloc] initWithImage:scaledImage
                                                           highlightedImage:storyMenuItemImagePressed
                                                               ContentImage:starImage
                                                    highlightedContentImage:nil];

    AwesomeMenuItem *starMenuItem5 = [[AwesomeMenuItem alloc] initWithImage:scaledImage
                                                           highlightedImage:storyMenuItemImagePressed
                                                               ContentImage:[UIImage imageNamed:@"Selector_Music_Fill"]
                                                    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"]];
    startItem.center = CGPointMake(self.tabBarController.tabBar.center.x , 30);

    //22
    self.menu = [[AwesomeMenu alloc] initWithFrame:CGRectMake(0, 0, 320, 568) startItem:startItem optionMenus:[NSArray arrayWithObjects:starMenuItem1, starMenuItem2, starMenuItem3, starMenuItem4, starMenuItem5,nil]];
    self.menu.startPoint = CGPointMake(160.0, 22.0);
    self.menu.rotateAngle = M_PI / 180 * -60;
    self.menu.menuWholeAngle = M_PI / 180 * 120;
    self.menu.timeOffset = 0.036f;
    self.menu.farRadius = 140.0f;
    self.menu.nearRadius = 110.0f;
    self.menu.endRadius = 120.0f;
    self.menu.delegate = self;
    self.menu.hidden = YES;
    [self.tabBarController.tabBar addSubview:self.menu];
    [self.tabBarController.tabBar sendSubviewToBack:self.menu];

以下是我如何从UITabBar中的按钮调用它:

[self.menu touchesBegan:nil withEvent:nil];

1 个答案:

答案 0 :(得分:0)

您必须在Tabbar中添加一个UIButton,触发初始化包含所有AwesomeMenu内容的空视图。您可以使用- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event将触摸事件从按钮传递到令人敬畏的菜单。不要在-(void)awesomeMenuDidFinishAnimationClose:(AwesomeMenu *)menu时忘记关闭ViewController。您还必须通过委托将所选的MenuItem传递给父vc。