Commit 5270cd03 authored by Matt Kane's avatar Matt Kane Committed by zooble

Allow user to specify picker row height on iOS (#204)

Allow user to specify row height for iOS
parent e8ff6cc7
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
|pickerToolBarFontSize | |number |16 | |pickerToolBarFontSize | |number |16 |
|wheelFlex | |array |[1, 1, 1] | |wheelFlex | |array |[1, 1, 1] |
|pickerFontSize | |number |16 | |pickerFontSize | |number |16 |
|pickerRowHeight | |number |24 |
|pickerFontColor | |array |[31, 31, 31, 1] | |pickerFontColor | |array |[31, 31, 31, 1] |
|pickerData | |array | | |pickerData | |array | |
|selectedValue | |array | | |selectedValue | |array | |
......
...@@ -148,6 +148,16 @@ interface PickerOptions { ...@@ -148,6 +148,16 @@ interface PickerOptions {
*/ */
pickerFontSize?: number pickerFontSize?: number
/**
* Row height of the items in the picker
*
* Default is 24
*
* @type {number}
* @memberof PickerOptions
*/
pickerRowHeight?: number
/** /**
* Color of the text for the items in the picker * Color of the text for the items in the picker
* *
......
...@@ -17,6 +17,7 @@ const options = { ...@@ -17,6 +17,7 @@ const options = {
pickerTitleColor: [20, 20, 20, 1], pickerTitleColor: [20, 20, 20, 1],
pickerToolBarBg: [232, 232, 232, 1], pickerToolBarBg: [232, 232, 232, 1],
pickerBg: [196, 199, 206, 1], pickerBg: [196, 199, 206, 1],
pickerRowHeight: 24,
wheelFlex: [1, 1, 1], wheelFlex: [1, 1, 1],
pickerData: [], pickerData: [],
selectedValue: [], selectedValue: [],
...@@ -29,7 +30,6 @@ const options = { ...@@ -29,7 +30,6 @@ const options = {
}; };
export default { export default {
init(params){ init(params){
const opt = { const opt = {
...options, ...options,
......
...@@ -41,7 +41,8 @@ typedef void(^backBolock)(NSDictionary * ); ...@@ -41,7 +41,8 @@ typedef void(^backBolock)(NSDictionary * );
@property(strong,nonatomic)NSString *rightStr; @property(strong,nonatomic)NSString *rightStr;
@property(strong,nonatomic)NSString *pickerToolBarFontSize; @property(strong,nonatomic)NSString *pickerToolBarFontSize;
@property(strong,nonatomic)NSString *pickerFontSize; @property(strong,nonatomic)NSString *pickerFontSize;
@property(strong,nonatomic)NSArray*pickerFontColor; @property(strong,nonatomic)NSArray *pickerFontColor;
@property(strong,nonatomic)NSString *pickerRowHeight;
...@@ -78,7 +79,7 @@ typedef void(^backBolock)(NSDictionary * ); ...@@ -78,7 +79,7 @@ typedef void(^backBolock)(NSDictionary * );
-(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSString *)leftStr centerStr:(NSString *)centerStr rightStr:(NSString *)rightStr topbgColor:(NSArray *)topbgColor bottombgColor:(NSArray *)bottombgColor leftbtnbgColor:(NSArray *)leftbtnbgColor rightbtnbgColor:(NSArray *)rightbtnbgColor centerbtnColor:(NSArray *)centerbtnColor selectValueArry:(NSArray *)selectValueArry weightArry:(NSArray *)weightArry -(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSString *)leftStr centerStr:(NSString *)centerStr rightStr:(NSString *)rightStr topbgColor:(NSArray *)topbgColor bottombgColor:(NSArray *)bottombgColor leftbtnbgColor:(NSArray *)leftbtnbgColor rightbtnbgColor:(NSArray *)rightbtnbgColor centerbtnColor:(NSArray *)centerbtnColor selectValueArry:(NSArray *)selectValueArry weightArry:(NSArray *)weightArry
pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor; pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight;
-(void)selectRow; -(void)selectRow;
@end @end
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
@implementation BzwPicker @implementation BzwPicker
-(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSString *)leftStr centerStr:(NSString *)centerStr rightStr:(NSString *)rightStr topbgColor:(NSArray *)topbgColor bottombgColor:(NSArray *)bottombgColor leftbtnbgColor:(NSArray *)leftbtnbgColor rightbtnbgColor:(NSArray *)rightbtnbgColor centerbtnColor:(NSArray *)centerbtnColor selectValueArry:(NSArray *)selectValueArry weightArry:(NSArray *)weightArry -(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSString *)leftStr centerStr:(NSString *)centerStr rightStr:(NSString *)rightStr topbgColor:(NSArray *)topbgColor bottombgColor:(NSArray *)bottombgColor leftbtnbgColor:(NSArray *)leftbtnbgColor rightbtnbgColor:(NSArray *)rightbtnbgColor centerbtnColor:(NSArray *)centerbtnColor selectValueArry:(NSArray *)selectValueArry weightArry:(NSArray *)weightArry
pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight
{ {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
self.pickerToolBarFontSize=pickerToolBarFontSize; self.pickerToolBarFontSize=pickerToolBarFontSize;
self.pickerFontSize=pickerFontSize; self.pickerFontSize=pickerFontSize;
self.pickerFontColor=pickerFontColor; self.pickerFontColor=pickerFontColor;
self.pickerRowHeight=pickerRowHeight;
[self getStyle]; [self getStyle];
[self getnumStyle]; [self getnumStyle];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
...@@ -469,6 +470,12 @@ ...@@ -469,6 +470,12 @@
self.bolock(dic); self.bolock(dic);
} }
} }
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return self.pickerRowHeight.integerValue;
}
//判断进来的类型是那种 //判断进来的类型是那种
-(void)getStyle -(void)getStyle
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#import "RCTBEEPickerManager.h" #import "RCTBEEPickerManager.h"
#import "BzwPicker.h" #import "BzwPicker.h"
#import "RCTEventDispatcher.h" #import <React/RCTEventDispatcher.h>
@interface RCTBEEPickerManager() @interface RCTBEEPickerManager()
...@@ -55,7 +55,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ ...@@ -55,7 +55,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]]; NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]];
NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]]; NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]];
NSArray *pickerFontColor=indic[@"pickerFontColor"]; NSArray *pickerFontColor=indic[@"pickerFontColor"];
NSString *pickerRowHeight=indic[@"pickerRowHeight"];
id pickerData=indic[@"pickerData"]; id pickerData=indic[@"pickerData"];
NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init]; NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
...@@ -78,10 +78,9 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ ...@@ -78,10 +78,9 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
}else{ }else{
self.height=220; self.height=220;
} }
self.pick=[[BzwPicker alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, self.height) dic:dataDic leftStr:pickerCancelBtnText centerStr:pickerTitleText rightStr:pickerConfirmBtnText topbgColor:pickerToolBarBg bottombgColor:pickerBg leftbtnbgColor:pickerCancelBtnColor rightbtnbgColor:pickerConfirmBtnColor centerbtnColor:pickerTitleColor selectValueArry:selectArry weightArry:weightArry pickerToolBarFontSize:pickerToolBarFontSize pickerFontSize:pickerFontSize pickerFontColor:pickerFontColor]; self.pick=[[BzwPicker alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, self.height) dic:dataDic leftStr:pickerCancelBtnText centerStr:pickerTitleText rightStr:pickerConfirmBtnText topbgColor:pickerToolBarBg bottombgColor:pickerBg leftbtnbgColor:pickerCancelBtnColor rightbtnbgColor:pickerConfirmBtnColor centerbtnColor:pickerTitleColor selectValueArry:selectArry weightArry:weightArry pickerToolBarFontSize:pickerToolBarFontSize pickerFontSize:pickerFontSize pickerFontColor:pickerFontColor pickerRowHeight: pickerRowHeight];
_pick.bolock=^(NSDictionary *backinfoArry){ _pick.bolock=^(NSDictionary *backinfoArry){
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment