项目作者: wwmz

项目描述 :
一个功能强大的表单组件,可自定义(A powerful form component that can be customized)
高级语言: Objective-C
项目地址: git://github.com/wwmz/WMZForm.git
创建时间: 2020-05-19T03:43:10Z
项目社区:https://github.com/wwmz/WMZForm

开源协议:MIT License

关键词:
form friendgroup setting

下载


WMZForm

先看看效果吧
| 实现页面 | 图片 |
|———————————-|——————————————————————————-|
| 单纯表单页面(可各种配置调样式) | 单纯表单.gif|
| 实现的一个简单朋友圈 | 朋友圈.gif|
| 简单实现一些设置的界面 | 设置.gif|
| 所有属性的页面-比较多比较杂乱 | 所有属性.gif|

简单一句话概括这个控件 - 表单~不止于表单

特效

  • 支持可自定义cell,cell需要继承于baseCell
  • 支持实现目前大多数表单的功能
  • 支持自定义选择弹窗的内容
  • 性能优化,高度缓存
  • 可链式可属性轻松调用
  • 可自定义cell上的ui控件
  • 可自定义无数据占位图

目前自带的样式介绍

  • FormCellDefault ~ 默认样式
    • FormCellNormal ~ 左右文本
  • FormCellIcon ~ 带图片+文本
    • FormCellInput ~ 单行输入框
  • FormCellText ~ 只有一个文本
    • FormCellTextView ~ 多行输入
  • FormCellVerification ~ 验证码输入
    • FormCellImage ~ 九宫格选择/显示图片
    • FormCellSwitch ~ 开关
    • FormCellCheck ~ 选择
    • FormCellTag ~ 标签
  • FormCellCommit ~ 按钮
    • FormCellEdit ~ 编辑
    • FormCellTakePicture~ 添加图片

用法介绍

初始化添加数据 - 属性有点多这里没法一次性说清 详情可以看demo 或者来问我

  1. //初始化
  2. WMZForm *form =
  3. Form(CGRectMake(0, NavigationBar_Form_Height, self.view.bounds.size.width , self.view.bounds.size.height - NavigationBar_Form_Height))
  4. //直接不带section 用row直接添加
  5. .wAddFormRow(^(WMZFormRowModel * _Nullable rowModel) {
  6. rowModel
  7. .wFormValue(@"AllPropertiesVC")
  8. .wFormName(@"全部属性demo")
  9. .wFormCellAccessoryType(UITableViewCellAccessoryDisclosureIndicator)
  10. .wFormShowLine(YES);
  11. });
  12. //直接section添加 WMZFormRowModel为子集
  13. .wAddFormSection(^(WMZFormSectionModel * _Nullable sectionModel) {
  14. //子集
  15. WMZFormRowModel *rowModel =
  16. FormRowModel()
  17. //tableviewCell的类名 自定义的时候传@"customCellName"你创建的cell的类名即可
  18. .wFormCellName(@(FormCellCommit))
  19. .wFormRowData(@{@"fill":@(YES),@"type":@(FormClickClick)})
  20. //自定义button
  21. .wFormCustomButton(^(UIButton * _Nullable button) {
  22. button.backgroundColor = [UIColor whiteColor];
  23. [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  24. })
  25. .wFormBtn(@"退出");
  26. sectionModel
  27. .wFormHeadHeight(20)
  28. .wFormFootHeight(20)
  29. //添加section的数据 rowModel组成的数据
  30. .wFormSectionData(@[rowModel])
  31. .wFormCellName(@(FormCellTag));
  32. });

直接添加也可以

  1. //添加row
  2. [form wAddFormRow:addModel atIndex:0];
  3. //添加section
  4. [form wAddFormSection:sectionModel atIndex:1];

代理方法

  1. /*
  2. *formCell点击
  3. @param cell 所在的cell (cell.model为model cell.indexPath 为其所在的indexPath)
  4. */
  5. - (void)form:(WMZForm*)form didSelectRowAtCell:(WMZFormBaseCell*)cell;
  6. /*
  7. *form提交
  8. @param commitInfo 提交的信息 为一个带value和key的字典
  9. @param success 是否通过检验规则可以提交
  10. */
  11. - (void)form:(WMZForm*)form info:(NSDictionary*)commitInfo canCommit:(BOOL)success;
  12. /*
  13. *formCell上的view点击 用于cell上的控件的交互事件
  14. @param clickView 点击的view
  15. @param cell 所在的cell
  16. @param action 根据action判断交互的事件
  17. */
  18. - (void)form:(WMZForm*)form
  19. subViewDidSelectRowAtCell:(WMZFormBaseCell*)cell
  20. view:(UIView*)clickView
  21. type:(id)action;

数据更新删除等 提供了多个实例方法

  1. //addRow 非初始化增加row调用 默认插入最后
  2. - (BOOL)wAddFormRow:(WMZFormRowModel*)rowModel;
  3. //addRow 非初始化增加row调用 插入index的位置 传入-1不刷新
  4. - (BOOL)wAddFormRow:(WMZFormRowModel*)rowModel atIndex:(NSInteger)index;
  5. //addRow 非初始化增加row调用 插入index的位置 传入-1不刷新
  6. - (BOOL)wAddFormRowBlock:(FormRowBlock)addFormRow atIndex:(NSInteger)index;
  7. //addSection 非初始化增加section调用 默认插入最后
  8. - (BOOL)wAddFormSection:(WMZFormSectionModel*)sectionModel;
  9. //addSection 非初始化增加section调用 插入index的位置 传入-1不刷新
  10. - (BOOL)wAddFormSection:(WMZFormSectionModel*)sectionModel atIndex:(NSInteger)index;
  11. //addSection 非初始化增加section调用 插入index的位置 传入-1不刷新
  12. - (BOOL)wAddFormSectionBlock:(FormSectionBlock)addFormSection atIndex:(NSInteger)index;
  13. //deleleSectionWithKey
  14. - (BOOL)wDeleteFormSectionWithKey:(NSString*)key;
  15. //deleleSectionWithKey
  16. - (BOOL)wDeleteFormSectionWithIndex:(NSInteger)index;
  17. //deleleRowWithKey
  18. - (BOOL)wDeleteFormRowWithKey:(NSString*)key;
  19. //deleleRowWithIndexPath
  20. - (BOOL)wDeleteFormRowWithIndexPath:(NSIndexPath*)indexPath;
  21. //reloadRow With key
  22. - (BOOL)wReloadRowWithKey:(NSString*)key;
  23. //reloadRow With indexPath
  24. - (BOOL)wReloadRowWithIndexPath:(NSIndexPath*)indexPath;
  25. //reloadSection With key
  26. - (BOOL)wReloadSectionWithKey:(NSString*)key;
  27. //reloadSection With index
  28. - (BOOL)wReloadSectionWithIndex:(NSInteger)index;
  29. //getRow With key
  30. - (WMZFormRowModel*)wFindRowModelWithKey:(NSString*)key;
  31. //getRow With indexPath
  32. - (WMZFormRowModel*)wFindRowModelWithIndexPath:(NSIndexPath*)indexPath;
  33. //getSection With key
  34. - (WMZFormSectionModel*)wFindSectionModelWithKey:(NSString*)key;
  35. //getSection With index
  36. - (WMZFormSectionModel*)wFindSectionModelWithIndex:(NSInteger)index;
  37. //reloadData
  38. - (void)wReloadData;
  39. //自定义刷新
  40. - (void)wReloadData:(FormCustomReload)block;

安装

CocoaPods

  1. 将 cocoapods 更新至最新版本.
  2. 在 Podfile 中添加 pod 'WMZForm'
  3. 执行 pod installpod update
  4. 导入 #import “WMZForm.h”。

注:要消除链式编程的警告

要在Buildding Settings 把CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF 设为NO

手动安装

  1. 下载 WMZForm 文件夹内的所有内容。
  2. 将 WMZForm 内的源文件和依赖的库添加(拖放)到你的工程。
  3. 导入 #import “WMZForm.h”

依赖

1WMZDialog(弹窗控件)
2 Masonry
3 SDWebImage
4 IQKeyboardManager

使用过程中如果有什么bug欢迎给我提issue 我看到就会解决
觉得有用的话给个star

简书地址