AwesomeMenu(美团)

AwesomeMenu(美团)_第1张图片
15093818-5f768e8d45a14ae08b703eb3ee032af8.png
- (void)viewDidLoad {
    [super viewDidLoad];
    
    AwesomeMenuItem *startItem = [[AwesomeMenuItem alloc]
                                  initWithImage:[UIImage imageNamed:@"123"]
                                  highlightedImage:[UIImage imageNamed:@"123"]
                                  ContentImage:[UIImage imageNamed:@"123"]
                                  highlightedContentImage:nil];
    
    //2. 添加其他几个按钮
    AwesomeMenuItem *item0 = [[AwesomeMenuItem alloc]
                              initWithImage:[UIImage imageNamed:@"1"]
                              highlightedImage:nil
                              ContentImage:[UIImage imageNamed:@"1"]
                              highlightedContentImage:[UIImage imageNamed:@"1"]];
    
    AwesomeMenuItem *item1 = [[AwesomeMenuItem alloc]
                              initWithImage:[UIImage imageNamed:@"2"]
                              highlightedImage:nil
                              ContentImage:[UIImage imageNamed:@"2"]
                              highlightedContentImage:[UIImage imageNamed:@"2"]];
    
    AwesomeMenuItem *item2 = [[AwesomeMenuItem alloc]
                              initWithImage:[UIImage imageNamed:@"3"]
                              highlightedImage:nil
                              ContentImage:[UIImage imageNamed:@"3"]
                              highlightedContentImage:[UIImage imageNamed:@"3"]];
    
    NSArray *MenuItems =@[item0,item1,item2];
    
 
    AwesomeMenu *menu = [[AwesomeMenu alloc]initWithFrame:CGRectZero startItem:startItem menuItems:MenuItems];
    
    [self.view addSubview:menu];
    
    //4. 禁止中间按钮旋转
    menu.rotateAddButton = NO;
    
    //5. 弹出范围
    menu.menuWholeAngle = M_PI_2;
    
    menu.animationDuration = 0.2;
    
    //6. 设置按钮位置
    menu.startPoint = CGPointMake(50, -100);
 
    [menu autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.view];
    [menu autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.view];
    
    //7. 设置代理
    menu.delegate = self;
    
    //8. 更改透明度
    menu.alpha = 0.5;
}
#pragma mark AwesomeMenu 代理方法
- (void)awesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx
{
    //1. 透明度
    menu.alpha = 0.5;
    
    //2. 更改图像
    
    
    
    switch (idx) {
        case 0:
            NSLog(@"0");
            menu.contentImage = [UIImage imageNamed:@"1"];
            //跳转控制器
            break;
            
        case 1:
            NSLog(@"1");
            menu.contentImage = [UIImage imageNamed:@"2"];
            break;
            
        case 2:
            NSLog(@"2");
            menu.contentImage = [UIImage imageNamed:@"3"];
            break;
        default:
            break;
    }
}
- (void)awesomeMenuWillAnimateOpen:(AwesomeMenu *)menu
{
    [UIView animateWithDuration:0.25 animations:^{
        //1. 透明度
        menu.alpha = 1;
        
      
    }];
}
- (void)awesomeMenuDidFinishAnimationClose:(AwesomeMenu *)menu
{
    //1. 透明度
    menu.alpha = 0.5;
    
}

你可能感兴趣的:(AwesomeMenu(美团))