程序员

用UIViewController写了个PopMenuView(

2018-12-22  本文已影响9人  呼呼兔

效果图如下

效果图

安装

  1. 使用cocoapods Podfile文件中添加pod 'ZLPopMenuViewController'
  2. 也可以直接把代码拖到工程中

使用

swift

        let datas1: [ZLPopMenuModel] = [.init(itemName: "首页(4)"),
                                        .init(itemName: "首页"),
                                        .init(itemName: "确认")]
        let popVC = ZLPopMenuViewController.init(sourceView: sender, menuData: datas1)
        popVC.didClickItems = {(index, model)in
            
        }
        present(popVC, animated: true, completion: nil)

Objective-C

        ZLPopMenuModel *model = [[ZLPopMenuModel alloc]initWithItemName:@"菜单" imageName:nil];
        
        ZLPopMenuViewController *popVC =[[ZLPopMenuViewController alloc] initWithSourceView:testView
                                                                                    menuData:@[model, model, model]
                                                                                   menuStyle:ZLPopMenuStyleWhite
                                                                               popMenuConfig:[ZLPopMenuConfig default]];
        [self presentViewController:popVC animated:true completion:nil];
        
        [popVC setDidClickItems:^(NSInteger indx, ZLPopMenuModel * _Nonnull model) {
            NSLog(@"OC中点击了 %ld, %@", indx, model);
        }];

最后放上地址ZLPopMenuViewController,也欢迎大家随意改样式。

上一篇 下一篇

猜你喜欢

热点阅读