diff --git a/README.md b/README.md index 16079cbcb08804e5c68f5b2a1b989d131b79157c..7d269b8fc834da4235d07be02033a2bf9b77e47d 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ |pickerToolBarFontSize | |number |16 | |wheelFlex | |array |[1, 1, 1] | |pickerFontSize | |number |16 | +|pickerRowHeight | |number |24 | |pickerFontColor | |array |[31, 31, 31, 1] | |pickerData | |array | | |selectedValue | |array | | diff --git a/index.d.ts b/index.d.ts index 5269d3a84c703dfe35765ff54c0320a6d603cd46..85c0616a28fc5a6760d754bf0116a608fbe8f1d0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -148,6 +148,16 @@ interface PickerOptions { */ 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 * diff --git a/index.js b/index.js index e1902b839e31cb647ff6172d71f5450e21cb6896..ec2af0f2652680594640b8624e886896ebbbabb7 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ const options = { pickerTitleColor: [20, 20, 20, 1], pickerToolBarBg: [232, 232, 232, 1], pickerBg: [196, 199, 206, 1], + pickerRowHeight: 24, wheelFlex: [1, 1, 1], pickerData: [], selectedValue: [], @@ -29,7 +30,6 @@ const options = { }; export default { - init(params){ const opt = { ...options, diff --git a/ios/RCTBEEPickerManager/BzwPicker.h b/ios/RCTBEEPickerManager/BzwPicker.h index 2642aa8885b72d19e8915faa438831a4f400c2f3..0da6fcf723d1fe662c3baa4ec88f86d882c56983 100755 --- a/ios/RCTBEEPickerManager/BzwPicker.h +++ b/ios/RCTBEEPickerManager/BzwPicker.h @@ -41,7 +41,8 @@ typedef void(^backBolock)(NSDictionary * ); @property(strong,nonatomic)NSString *rightStr; @property(strong,nonatomic)NSString *pickerToolBarFontSize; @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 * ); -(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; @end diff --git a/ios/RCTBEEPickerManager/BzwPicker.m b/ios/RCTBEEPickerManager/BzwPicker.m index 9ab529a4dfc33ccff826ba236577cb594d0fe506..f1b7fe23bea46f2ad5a0e0017fa82bb304ff8495 100755 --- a/ios/RCTBEEPickerManager/BzwPicker.m +++ b/ios/RCTBEEPickerManager/BzwPicker.m @@ -12,7 +12,7 @@ @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 - 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]; @@ -30,6 +30,7 @@ self.pickerToolBarFontSize=pickerToolBarFontSize; self.pickerFontSize=pickerFontSize; self.pickerFontColor=pickerFontColor; + self.pickerRowHeight=pickerRowHeight; [self getStyle]; [self getnumStyle]; dispatch_async(dispatch_get_main_queue(), ^{ @@ -469,6 +470,12 @@ self.bolock(dic); } } + +- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component +{ + return self.pickerRowHeight.integerValue; +} + //判断进来的类型是那种 -(void)getStyle { diff --git a/ios/RCTBEEPickerManager/RCTBEEPickerManager.m b/ios/RCTBEEPickerManager/RCTBEEPickerManager.m index 7820e365a1e48195e5262ad5a5c1265dfb83843a..2721ae3265c79b4c3608263dad11f1372c76c7ca 100644 --- a/ios/RCTBEEPickerManager/RCTBEEPickerManager.m +++ b/ios/RCTBEEPickerManager/RCTBEEPickerManager.m @@ -8,7 +8,7 @@ #import "RCTBEEPickerManager.h" #import "BzwPicker.h" -#import "RCTEventDispatcher.h" +#import @interface RCTBEEPickerManager() @@ -55,7 +55,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]]; NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]]; NSArray *pickerFontColor=indic[@"pickerFontColor"]; - + NSString *pickerRowHeight=indic[@"pickerRowHeight"]; id pickerData=indic[@"pickerData"]; NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init]; @@ -78,10 +78,9 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ }else{ 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){ dispatch_async(dispatch_get_main_queue(), ^{