一个iOS表单框架-UFKit

          _ _     _ _   _ _ _ _ _   _ _    _ _     _ _   _ _ _ _ _ _ __
         /  /    /  /  /  _ _ _ /  /  /   ╱  ╱    /__/  /_ _ _   _ _ _/
        /  /    /  /  /  /        /  /  ╱  ╱     _ _         /  /
       /  /    /  /  /  /_ _ _   /  / ╱  ╱      /  /        /  /
      /  /    /  /  /  _ _ _ /  /  / \  \      /  /        /  /
     /  /_ __/  /  /  /        /  /   \  \    /  /        /  /
     \ _ _ _ _ /  /__/        /__/     \__\  /__/        /__/

效果

在这里插入图片描述

1、表单UFFormView
UFFormView *formView = [UFFormView makeFormView:^(UFFormViewMaker * _Nonnull make) {
        // TODO:设置表单样式
    }];

或者

UFFormView *formView = [[UFFormView alloc] init];
// TODO:设置表单样式
2、表单样式
1、什么是样式?

样式就是设置UI控件的字体、颜色、对齐方式等一列属性。包括:文本样式UFTextStyle、标题样式UFRowTitleStyle、手机验证码按钮样式UFMobileCodeStyle、单选按钮样式UFRadioGroupStyle、表单组样式UFSectionStyle等。

2、如何创建表单样式?

​ 1、文本样式

UFTextStyle *textStyle = [UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
        make
        .color([UIColor redColor])            // 设置文本颜色
        .font([UIFont systemFontOfSize:14])   // 设置文本字体
        .textAlignment(NSTextAlignmentLeft);  // 设置文本对齐方式
    }];     

或者

UFTextStyle *textStyle = [[UFTextStyle alloc] init];
textStyle.color = [UIColor redColor];           // 设置文本颜色
textStyle.font = [UIFont systemFontOfSize:14];  // 设置文本字体
textStyle.textAlignment = NSTextAlignmentLeft;  // 设置文本对齐方式

​ 2、标题样式

UFRowTitleStyle *titleStyle = [UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
        make
        .width(90)                           // 设置标题宽度
        .color([UIColor redColor])           // 设置标题颜色
        .font([UIFont systemFontOfSize:14])  // 设置标题字体
        .textAlignment(NSTextAlignmentLeft); // 设置标题对齐方式
    }];     

UFRowTitleStyle *titleStyle = [[UFTextStyle alloc] init];
titleStyle.width = 90;                           // 设置标题宽度
titleStyle.color = [UIColor redColor];           // 设置标题颜色
titleStyle.font = [UIFont systemFontOfSize:14];  // 设置标题字体
titleStyle.textAlignment = NSTextAlignmentLeft;  // 设置标题对齐方式

​ 3、手机验证码样式

UFMobileCodeStyle *codeStyle = [UFMobileCodeStyle makeMobileCodeStyle:^(UFMobileCodeStyleMaker * _Nonnull make) {
        make
        .cornerRadius(10)                           // 设置按钮圆角
        .backgroundColor([UIColor redColor])        // 设置按钮背景色
        .separatorColor([UIColor lightGrayColor])   // 设置输入框与按钮之间分割线的颜色
        .color([UIColor whiteColor])                // 设置按钮标题颜色
        .font([UIFont systemFontOfSize:14])         // 设置按钮标题字体
        .textAlignment(NSTextAlignmentLeft);        // 设置按钮标题对齐方式
    }];

UFMobileCodeStyle *codeStyle = [[UFMobileCodeStyle alloc] init];
codeStyle.cornerRadius = 10;                         // 设置按钮圆角     
codeStyle.backgroundColor = [UIColor redColor];      // 设置按钮背景色
codeStyle.separatorColor = [UIColor lightGrayColor]  // 设置输入框与按钮之间分割线的颜色
codeStyle.color = [UIColor whiteColor];              // 设置按钮标题颜色
codeStyle.font = [UIFont systemFontOfSize:14];       // 设置按钮标题字体
codeStyle.textAlignment = NSTextAlignmentLeft;       // 设置按钮标题对齐方式

​ 4、单选按钮样式

UFRadioGroupStyle *radioGroupStyle = [UFRadioGroupStyle makeRadioGroupStyle:^(UFRowRadioGroupStyleMaker * _Nonnull make) {
        make
        .image([UIImage imageNamed:@"radio_checked"])              // 未选中图片
        .selectedImage([UIImage imageNamed:@"radio_unchecked"]);   // 选中图片
    }];

UFRadioGroupStyle *radioGroupStyle = [[UFRadioGroupStyle alloc] init];
radioGroupStyle.image = [UIImage imageNamed:@"radio_checked"];             // 未选中图片
radioGroupStyle.selectedImage = [UIImage imageNamed:@"radio_unchecked"];   // 选中图片
3、统一添加表单样式

1、添加左侧标题样式

[UFFormView makeFormView:^(UFFormViewMaker * _Nonnull make) {
        make
        .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {                                
	// TODO:设置标题样式(参考如何创建标题样式)
        }]);
    }];    

UFRowTitleStyle *titleStyle = [[UFRowTitleStyle alloc] init];
// TODO:设置标题样式(参考如何创建标题样式)
formView.titleStyle = titleStyle;    

2、设置右侧值样式

UFFormView *formView = [UFFormView makeFormView:^(UFFormViewMaker * _Nonnull make) {
            make
            .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
                // TODO:设置值样式(参考如何创建文本样式)
            }]);
     }];    

UFTextStyle *valueStyle = [[UFTextStyle alloc] init];
// TODO:设置值样式(参考如何创
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值