JRDropMenu 1.0.3

JRDropMenu 1.0.3

andy123234 维护。



JRDropMenu



真机美图

单列表 有前缀的标题 默认选中项
image1 image1 image1
自定义标题样式 自定义列表样式 选中不替换标题Index
image1 image1 image1

使用前安装

CocoaPods 安装 (推荐)

  1. Podfile 中添加以下内容
pod 'JRDropMenu', :git => 'https://github.com/andy123234/JRDropMenu.git'
  1. 执行 pod installpod update

手动安装

1. 将项目Demo中的文件夹JRDropMenu拖入到所需项目中.

2. 在你的项目的 .pch 全局宏定义文件中添加

#import "JRGlobalMacro.h"

正式开始使用

1. 在你的ViewController视图控制器文件中添加

#import "JRDropMenuView.h"

2. 创建视图JRDropMenuView

self.menuView = [[JRDropMenuView alloc] initWithFrame:CGRectMake(00, 88, [UIScreen mainScreen].bounds.size.width, 44)];
self.menuView.delegate = self;
[self.menuView createJRDropMenuViewWithOption:[self option]];
[self.view addSubview:self.menuView];

3. JRCategory需包含JRTitle和JRList属性完成一列下拉菜单的配置

JRCategory -> JRTitle + JRList = JROption

- (JROption *)option
{
    JROption * option = JROption.new
   .categoryArrSet(@[
                       JRCategory.new
                       .titleSet(JRTitle.new
                                 .titleNameSet(@"标题名称")
                                 )
                       .listSet(JRList.new
                                .listArrSet(列表数组)
                                )
                     ]
                   );
   return option;
}

4. 自定义标题和列表属性

根据JROption, JRTitle和JRList的头文件来选择需要自定义的属性, 使用点语法即可轻松完成配置

JROption * option = JROption.new
.categoryArrSet(@[
                    JRCategory.new
                    .titleSet(JRTitle.new
                              .titleNameSet(@"Language")
                              .titleSelectedTintColorSet([UIColor blackColor])
                              .titleNormalTintColorSet([UIColor whiteColor])
                              .titleNormalFontSet([UIFont systemFontOfSize:12])
                              .titleNormalBgColorSet([UIColor colorWithRed:6/255.0 green:26/255.0 blue:52/255.0 alpha:.8])
                              )
                    .listSet(JRList.new
                             .listArrSet(@[@"ALL",@"PHP",@"OC",@"Swift",@"Java",@"JavaScript"])
                             .listRowHeightSet(60)
                             .listNormalBgColorSet([UIColor lightGrayColor])
                             .listNormalTintColorSet([UIColor redColor])
                             )
                  ]
                )
.showIndicatorSet(NO);
return option;

5. 移除视图

在即将离开视图时需要调用 dismiss 方法,并关闭动画。

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self.menuView dismissWithAnimation:NO];
}

特别说明

获取点击事件结果

可以通过为 JRDropMenuView 示例对象设置代理方法,来实现用户点击事件的监听。

- (void)jrDropMenuView:(JRDropMenuView *)jrDropMenuView ResultArr:(NSMutableArray <JRDropMenuItemModel *>*)resultArr;