_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __
/ / / / / _ _ _ / / / ╱ ╱ /__/ /_ _ _ _ _ _/
/ / / / / / / / ╱ ╱ _ _ / /
/ / / / / /_ _ _ / / ╱ ╱ / / / /
/ / / / / _ _ _ / / / \ \ / / / /
/ /_ __/ / / / / / \ \ / / / /
\ _ _ _ _ / /__/ /__/ \__\ /__/ /__/
效果
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:设置值样式(参考如何创