Latest 0.0.4
Homepage https://github.com/adampei/AwFilterView
License MIT
Platforms ios 8.0, requires ARC
Authors

筛选框

image

通过模型初始化视图对应的每一个选项

用法以及注意事项

初始化并加入控制器的view中

AwFilterView * filterView = [[AwFilterView alloc] initWithFrame:CGRectMake(0, 100, 300, 180)];
[self.view addSubview:filterView];
  • 可选项是单选类型还是多选类型,通过设置属性filterView.selectType = KSelectType_Muti;多选,KSelectType_Single单选
  • 设置每个选项大小,用filterView.size = CGSizeMake(70, 30);
  • 设置每一行选项个数filterView.numsOfSingleLine = 3;
  • 选项距离view顶部距离filterView.marginTop = 20;
  • 选项距离view左侧距离filterView.margin = 15;

image

创建模型

AwFilterItem * item = [[AwFilterItem alloc] init];
// 正常状态背景颜色
item.colorBgNormal = [UIColor orangeColor];
// 选中状态背景色
item.colorBgSelected = [UIColor yellowColor];
// 标题
item.title = @"已读";
// 此选项是否被选中状态
item.isSelected = NO;
// 正常字体颜色
item.colorNormal = [UIColor blackColor];
// 选中状态字体颜色
item.colorSelected = [UIColor redColor];
  • 还可以设置item的圆角item.raidus = 8;
  • 设置字体大小item.fontBtn

将模型给了filterView

[filterView addItemsWithArr:@[item, item2, item3, item4]];

filterView方法

  • 设置全选
[self.filterView resetStatusWithType:KResetStatus_Selected];
  • 全部取消选择
[self.filterView resetStatusWithType:KResetStatus_DeSelected];

filterView的选择模式

  • 选择0个或者1个
self.filterView.selectType = KSelectType_Single;
  • 选择0个或者多个
self.filterView.selectType = KSelectType_Muti;
  • 只能选一个
self.filterView.isForceSelect = YES;
  • 可以选择一个或者多个则组合一下同时设置以下两个属性
self.filterView.selectType = KSelectType_Muti;
self.filterView.isForceSelect = YES;

选择后的回调方法

  • 将所有的模型回调回来, 根据回调回来的模型你可以做操作
[filterView setClickBtnCallback:^(NSArray<AwFilterItem *> *arrItems) {

}];

Latest podspec

{
    "name": "AwFilterView",
    "version": "0.0.4",
    "summary": "u81eau5b9au4e49u7b5bu9009u5e93",
    "description": "u4e00u4e2au81eau5b9au4e49u7684u7b5bu9009u5e93",
    "homepage": "https://github.com/adampei/AwFilterView",
    "license": "MIT",
    "authors": {
        "u88f4u6ce2u6ce2": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/adampei/AwFilterView.git",
        "tag": "0.0.4"
    },
    "source_files": "demo/AwFilterView",
    "requires_arc": true
}

Pin It on Pinterest

Share This