一个iOS表单框架-UFKit
生活随笔
收集整理的這篇文章主要介紹了
一个iOS表单框架-UFKit
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
效果:
使用:
pod 'UFKit'- (void)viewDidLoad {[super viewDidLoad];__block UFFormView *formView = [UFFormView makeFormView:^(UFFormViewMaker * _Nonnull make) {make.addSection([UFSection makeSection:^(UFSectionMaker * _Nonnull make) {make.addRow([UFAvatarRow makeAvatarRow:^(UFAvatarRowMaker * _Nonnull make) {make.cornerRadius(30).avatarImage([UIImage imageNamed:@"touxiang"]).avatarDidSelected(^(__kindof UFAvatarRow * _Nonnull row, UIImageView * _Nonnull avatarView) {NSLog(@"你點擊了頭像");}).title(@"頭像").value(@"http://img0.imgtn.bdimg.com/it/u=2572957358,1108684168&fm=26&gp=0.jpg").name(@"avatar").accessoryType(UFRowAccessorySpace);}]).addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {make.title(@"姓名").value(@"蘋果").name(@"name").accessoryType(UFRowAccessorySpace);}]).addRow([UFRadioGroupRow makeRadioGroupRow:^(UFRadioGroupRowMaker * _Nonnull make) {make.itemArray(@[@"男",@"女"]).title(@"性別").value(@"男").name(@"gender").accessoryType(UFRowAccessorySpace);}]).addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {make.maxLength(11).regex(@"^[1][3-9]*$").keyboardType(UIKeyboardTypeNumberPad).title(@"聯(lián)系方式").name(@"mobile").accessoryType(UFRowAccessorySpace);}]).addRow([UFMobileCodeRow makeCodeRow:^(UFCodeRowMaker * _Nonnull make) {make.codeStyle([UFMobileCodeStyle makeMobileCodeStyle:^(UFMobileCodeStyleMaker * _Nonnull make) {}]).codeDidClicked(^(__kindof UFMobileCodeRow * _Nonnull row, UIButton * _Nonnull button) {NSLog(@"點了了獲取驗證碼");}).maxLength(4).keyboardType(UIKeyboardTypeNumberPad).title(@"驗證碼").name(@"code").accessoryType(UFRowAccessorySpace);}]).addRow([UFPickerViewRow makePickerViewRow:^(UFPickerViewRowMaker * _Nonnull make) {make.itemArray(@[@"iOS",@"macOS",@"swift",@"iPhone",@"iPad",@"iPod"]).title(@"技能").value(@"iOS").name(@"skills").accessoryType(UFRowAccessoryDisclosureIndicator);}]).addRow([UFMultiplePickerViewRow makeMultiplePickerViewRow:^(UFMultiplePickerViewRowMaker * _Nonnull make) {make.itemArray(@[@"看電影",@"旅游",@"看書",@"打游戲",@"籃球",@"足球",@"其他"]).title(@"愛好").value(@"打游戲,其他").name(@"hobby").accessoryType(UFRowAccessoryDisclosureIndicator);}]).addRow([UFDatePickerRow makeDatePickerRow:^(UFDatePickerRowMaker * _Nonnull make) {make.datePickerMode(UIDatePickerModeDate).dateFormat(@"yyyy-MM-dd").title(@"生日").name(@"birthday").accessoryType(UFRowAccessoryDisclosureIndicator);}]).addRow([UFSwitchRow makeSwitchRow:^(UFSwitchRowMaker * _Nonnull make) {make.tintColor([UIColor redColor]).title(@"免打擾").value(SWITCH_ON).name(@"allow").accessoryType(UFRowAccessorySpace).valueDidChanged(^(__kindof UFRow * _Nonnull row, __kindof NSString * _Nonnull value) {if ([row.value boolValue]) {NSLog(@"開");} else {NSLog(@"關(guān)");}});}]).addRow([UFPlateNumberRow makePlateNumberRow:^(UFPlateNumberRowMaker * _Nonnull make) {make.title(@"車牌號").value(@"魯A123456").name(@"plate").accessoryType(UFRowAccessorySpace);}]).addRow([UFTextViewRow makeTextViewRow:^(UFTextViewRowMaker * _Nonnull make) {make.maxLength(120).title(@"個人簡介").value(@"蘋果公司是美國一家高科技公司。由史蒂夫·喬布斯、斯蒂夫·沃茲尼亞克和羅·韋恩等人于1976年4月1日創(chuàng)立,總部位于加利福尼亞州的庫比蒂諾").name(@"introduction").accessoryType(UFRowAccessorySpace);}]);}]).addSubmitButton([UFActionButton makeActionButton:^(UFActionButtonMaker * _Nonnull make) {make.titleForState(@"提交", UIControlStateNormal).titleColorForState([UIColor whiteColor], UIControlStateNormal).cornerRadius(17).backgroundColor([UIColor redColor]).actionButtonClick(^(UFActionButton * _Nonnull button) {NSLog(@"提交的信息:\n%@",[formView toDictionary]);});}]).addToSuperView(self.view);}];[formView mas_makeConstraints:^(MASConstraintMaker *make) {make.edges.mas_equalTo(self.view);}]; }復(fù)制代碼依賴:
'Masonry', '~> 1.1.0'
'SDWebImage', '~> 5.0.6'
'IQKeyboardManager', '~> 6.3.0'
github
轉(zhuǎn)載于:https://juejin.im/post/5d39753b518825634532565d
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的一个iOS表单框架-UFKit的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 「PKUWC2018」Slay the
- 下一篇: Linux和Windows两个系统存在,