一个功能强大的表单组件,可自定义(A powerful form component that can be customized)
先看看效果吧
| 实现页面 | 图片 |
|———————————-|——————————————————————————-|
| 单纯表单页面(可各种配置调样式) | |
| 实现的一个简单朋友圈 | |
| 简单实现一些设置的界面 | |
| 所有属性的页面-比较多比较杂乱 | |
//初始化
WMZForm *form =
Form(CGRectMake(0, NavigationBar_Form_Height, self.view.bounds.size.width , self.view.bounds.size.height - NavigationBar_Form_Height))
//直接不带section 用row直接添加
.wAddFormRow(^(WMZFormRowModel * _Nullable rowModel) {
rowModel
.wFormValue(@"AllPropertiesVC")
.wFormName(@"全部属性demo")
.wFormCellAccessoryType(UITableViewCellAccessoryDisclosureIndicator)
.wFormShowLine(YES);
});
//直接section添加 WMZFormRowModel为子集
.wAddFormSection(^(WMZFormSectionModel * _Nullable sectionModel) {
//子集
WMZFormRowModel *rowModel =
FormRowModel()
//tableviewCell的类名 自定义的时候传@"customCellName"你创建的cell的类名即可
.wFormCellName(@(FormCellCommit))
.wFormRowData(@{@"fill":@(YES),@"type":@(FormClickClick)})
//自定义button
.wFormCustomButton(^(UIButton * _Nullable button) {
button.backgroundColor = [UIColor whiteColor];
[button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
})
.wFormBtn(@"退出");
sectionModel
.wFormHeadHeight(20)
.wFormFootHeight(20)
//添加section的数据 rowModel组成的数据
.wFormSectionData(@[rowModel])
.wFormCellName(@(FormCellTag));
});
//添加row
[form wAddFormRow:addModel atIndex:0];
//添加section
[form wAddFormSection:sectionModel atIndex:1];
/*
*formCell点击
@param cell 所在的cell (cell.model为model cell.indexPath 为其所在的indexPath)
*/
- (void)form:(WMZForm*)form didSelectRowAtCell:(WMZFormBaseCell*)cell;
/*
*form提交
@param commitInfo 提交的信息 为一个带value和key的字典
@param success 是否通过检验规则可以提交
*/
- (void)form:(WMZForm*)form info:(NSDictionary*)commitInfo canCommit:(BOOL)success;
/*
*formCell上的view点击 用于cell上的控件的交互事件
@param clickView 点击的view
@param cell 所在的cell
@param action 根据action判断交互的事件
*/
- (void)form:(WMZForm*)form
subViewDidSelectRowAtCell:(WMZFormBaseCell*)cell
view:(UIView*)clickView
type:(id)action;
//addRow 非初始化增加row调用 默认插入最后
- (BOOL)wAddFormRow:(WMZFormRowModel*)rowModel;
//addRow 非初始化增加row调用 插入index的位置 传入-1不刷新
- (BOOL)wAddFormRow:(WMZFormRowModel*)rowModel atIndex:(NSInteger)index;
//addRow 非初始化增加row调用 插入index的位置 传入-1不刷新
- (BOOL)wAddFormRowBlock:(FormRowBlock)addFormRow atIndex:(NSInteger)index;
//addSection 非初始化增加section调用 默认插入最后
- (BOOL)wAddFormSection:(WMZFormSectionModel*)sectionModel;
//addSection 非初始化增加section调用 插入index的位置 传入-1不刷新
- (BOOL)wAddFormSection:(WMZFormSectionModel*)sectionModel atIndex:(NSInteger)index;
//addSection 非初始化增加section调用 插入index的位置 传入-1不刷新
- (BOOL)wAddFormSectionBlock:(FormSectionBlock)addFormSection atIndex:(NSInteger)index;
//deleleSectionWithKey
- (BOOL)wDeleteFormSectionWithKey:(NSString*)key;
//deleleSectionWithKey
- (BOOL)wDeleteFormSectionWithIndex:(NSInteger)index;
//deleleRowWithKey
- (BOOL)wDeleteFormRowWithKey:(NSString*)key;
//deleleRowWithIndexPath
- (BOOL)wDeleteFormRowWithIndexPath:(NSIndexPath*)indexPath;
//reloadRow With key
- (BOOL)wReloadRowWithKey:(NSString*)key;
//reloadRow With indexPath
- (BOOL)wReloadRowWithIndexPath:(NSIndexPath*)indexPath;
//reloadSection With key
- (BOOL)wReloadSectionWithKey:(NSString*)key;
//reloadSection With index
- (BOOL)wReloadSectionWithIndex:(NSInteger)index;
//getRow With key
- (WMZFormRowModel*)wFindRowModelWithKey:(NSString*)key;
//getRow With indexPath
- (WMZFormRowModel*)wFindRowModelWithIndexPath:(NSIndexPath*)indexPath;
//getSection With key
- (WMZFormSectionModel*)wFindSectionModelWithKey:(NSString*)key;
//getSection With index
- (WMZFormSectionModel*)wFindSectionModelWithIndex:(NSInteger)index;
//reloadData
- (void)wReloadData;
//自定义刷新
- (void)wReloadData:(FormCustomReload)block;
pod 'WMZForm'
。pod install
或 pod update
。要在Buildding Settings 把CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF 设为NO
1WMZDialog(弹窗控件)
2 Masonry
3 SDWebImage
4 IQKeyboardManager
使用过程中如果有什么bug欢迎给我提issue 我看到就会解决
觉得有用的话给个star