基于CMuneBar完成的两侧展开动画

作者: 再见远洋 | 来源:发表于2016-07-22 15:37 被阅读126次

首先,感谢原作者提供的CMuneBar这个demo 地址如下:https://github.com/CaoWeikang/CMuneBarDemo
原文提供了很多种效果,如扇形展开菜单,单侧展开菜单等效果,都是基于贝塞尔曲线来做的,我今天要说的效果和demo里面的其中一种效果是类似的,不解释,看图:
demo里面的效果图:

演示.gif

我要实现的效果是gif图片中的第5中效果和第6中效果叠加到一起的效果,也就是两边都要展开,点击中间的菜单按钮如图:

2016-07-22 15_37_17.gif

我在原文的基础上加了一个旋转的动画,具体你可以看下代码,效果还是不错的,我的实现思路是添加两个菜单按钮,分别添加第5和第6种效果,代码如下:

    CMuneBar *muneBar = [[CMuneBar alloc] initWithItems:@[@"camera",@"draw"] size:CGSizeMake(50, 50) type:kMuneBarTypeLineLeft];
    muneBar.firstDelegate = self;
    muneBar.center = self.view.center;
    [self.view addSubview:muneBar];
    self.muneBar = muneBar;
    
    
    CMuneBar *secondMuneBar = [[CMuneBar alloc] initWithItems:@[@"gallery",@"dropbox"] size:CGSizeMake(50, 50) type:kMuneBarTypeLineRight];
    secondMuneBar.delegate = self;
    secondMuneBar.center = self.view.center;
    [self.view addSubview:secondMuneBar];
    self.secondMuneBar = secondMuneBar;
/**
 *  右边item点击代理事件
 *
 *  @param index 索引
 */
-(void)muneBarselected:(NSInteger)index{
    NSLog(@"%@",@(index));
}

- (void)muneBarShow {
    [self.muneBar showItems];
    NSLog(@"展开");
}

- (void)muneBarHide {
    NSLog(@"显示");
}

/**
 *  左边item点击代理事件
 *
 *  @param index 索引
 */- (void)firstMuneBarselected:(NSInteger)index {
    NSLog(@"%@",@(index));
}

具体的代码和详情大家看代码吧,毕竟是根据别人的demo来改写的,具体如何使用大家也可以参考上面我给出的地址

相关文章

网友评论

    本文标题:基于CMuneBar完成的两侧展开动画

    本文链接:https://www.haomeiwen.com/subject/cgeijttx.html