Open MrCodeHauler opened 1 year ago
/// 多列字符串
BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]init];
stringPickerView.pickerMode = BRStringPickerComponentMulti;
stringPickerView.dataSourceArr = @[@[@"01", @"02", @"03", @"04", @"05", @"06", @"07", @"08", @"09", @"10", @"11", @"12"], @[@"00", @"10", @"20", @"30", @"40", @"50"]];
stringPickerView.isAutoSelect = YES;
stringPickerView.resultModelArrayBlock = ^(NSArray<BRResultModel *> *resultModelArr) {
textField.text = [NSString stringWithFormat:@"%@:%@", resultModelArr[0].value, resultModelArr[1].value];
};
// 设置自定义样式
BRPickerStyle *customStyle = [[BRPickerStyle alloc]init];
// 设置 picker 的列宽
customStyle.columnWidth = 30;
// 设置 picker 的列间隔
customStyle.columnSpacing = 60;
// 设置圆角矩形背景
// 方式1:使用系统自带样式,保留iOS14之后系统默认的圆角样式
customStyle.clearPickerNewStyle = NO;
// 方式2:可以使用UIView自定义一个圆角矩形视图rectView,并添加到 alertView 上也能实现同样的效果([stringPickerView.alertView addSubview:rectView];)
// 设置选择器中间选中行的样式
customStyle.selectRowTextFont = [UIFont boldSystemFontOfSize:20.0f];
customStyle.selectRowTextColor = [UIColor blueColor];
stringPickerView.pickerStyle = customStyle;
[stringPickerView show];