前言: 都2020年了 之前接觸過有兩個項目,那種詳情頁面,表單編輯頁面,還在用scrollerView 然后一個個label加 综膀,整個頁面又臃腫又長,想要改點什么都特別麻煩 布局都會亂,心中真是改的在滴血楞陷。
控件 WMZForm 一個簡單使用的表單應運而生
還是先看看效果吧
實現(xiàn)頁面 | 圖片 |
---|---|
單純表單頁面(可各種配置調樣式) | 單純表單.gif
|
實現(xiàn)的一個簡單朋友圈 | 朋友圈.gif
|
簡單實現(xiàn)一些設置的界面 | 設置.gif
|
所有屬性的頁面-比較多比較雜亂 | 所有屬性.gif
|
簡單一句話概括這個控件 - 表單~不止于表單
特效
- 支持可自定義cell,cell需要繼承于baseCell
- 支持實現(xiàn)目前大多數(shù)表單的功能
- 支持自定義選擇彈窗的內容
- 性能優(yōu)化,高度緩存
- 可鏈式可屬性輕松調用
- 可自定義cell上的ui控件
目前自帶的樣式介紹
- FormCellDefault ~ 默認樣式
- FormCellNormal ~ 左右文本
- FormCellIcon ~ 帶圖片+文本
- FormCellInput ~ 單行輸入框
- FormCellText ~ 只有一個文本
- FormCellTextView ~ 多行輸入
- FormCellVerification ~ 驗證碼輸入
- FormCellImage ~ 九宮格選擇/顯示圖片
- FormCellSwitch ~ 開關
- FormCellCheck ~ 選擇
- FormCellTag ~ 標簽
- FormCellCommit ~ 按鈕
- FormCellEdit ~ 編輯
- FormCellTakePicture~ 添加圖片
用法介紹
初始化添加數(shù)據(jù) - 屬性有點多這里沒法一次性說清 詳情可以看demo 或者來問我
//初始化
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"你創(chuàng)建的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的數(shù)據(jù) rowModel組成的數(shù)據(jù)
.wFormSectionData(@[rowModel])
.wFormCellName(@(FormCellTag));
});
代理方法
/*
*formCell點擊
@param cell 所在的cell (cell.model為model cell.indexPath 為其所在的indexPath)
*/
- (void)form:(WMZForm*)form didSelectRowAtCell:(WMZFormBaseCell*)cell;
/*
*form提交
@param commitInfo 提交的信息 為一個帶value和key的字典
@param success 是否通過檢驗規(guī)則可以提交
*/
- (void)form:(WMZForm*)form info:(NSDictionary*)commitInfo canCommit:(BOOL)success;
/*
*formCell上的view點擊 用于cell上的控件的交互事件
@param clickView 點擊的view
@param cell 所在的cell
@param action 根據(jù)action判斷交互的事件
*/
- (void)form:(WMZForm*)form
subViewDidSelectRowAtCell:(WMZFormBaseCell*)cell
view:(UIView*)clickView
type:(id)action;
數(shù)據(jù)更新刪除等 提供了多個實例方法
//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;
安裝
CocoaPods
- 將 cocoapods 更新至最新版本.
- 在 Podfile 中添加
pod 'WMZForm'
坪它。 - 執(zhí)行
pod install
或pod update
。 - 導入 #import "WMZForm.h"吩翻。
注:要消除鏈式編程的警告
要在Buildding Settings 把CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF 設為NO
手動安裝
- 下載 WMZForm 文件夾內的所有內容婴洼。
- 將 WMZForm 內的源文件和依賴的庫添加(拖放)到你的工程骨坑。
- 導入 #import "WMZForm.h"
依賴
1WMZDialog(彈窗控件)
2 Masonry
3 SDWebImage
4 IQKeyboardManager
使用過程中如果有什么bug歡迎給我提issue 我看到就會解決
覺得有用的話給個star