Commit 6af175d6 authored by xwenliang's avatar xwenliang

new feature pickerFontFamily for both android and ios

parent 0e39dea0
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
|wheelFlex | array | [1, 1, 1] | iOS/Android | | |wheelFlex | array | [1, 1, 1] | iOS/Android | |
|pickerFontSize | number | 16 | iOS/Android | | |pickerFontSize | number | 16 | iOS/Android | |
|pickerFontColor | array | [31, 31, 31, 1] | iOS/Android | | |pickerFontColor | array | [31, 31, 31, 1] | iOS/Android | |
|pickerFontFamily | string | | Android | | |pickerFontFamily | string | | iOS/Android | |
|pickerRowHeight | number | 24 | iOS | | |pickerRowHeight | number | 24 | iOS | |
|pickerData | array | | iOS/Android | | |pickerData | array | | iOS/Android | |
|selectedValue | array | | iOS/Android | | |selectedValue | array | | iOS/Android | |
......
...@@ -60,7 +60,7 @@ interface PickerOptions { ...@@ -60,7 +60,7 @@ interface PickerOptions {
* @type {string} * @type {string}
* @memberof PickerOptions * @memberof PickerOptions
*/ */
pickerCancelBtnText: string pickerCancelBtnText?: string
/** /**
* The color of the text for the confirm button * The color of the text for the confirm button
......
...@@ -41,6 +41,7 @@ typedef void(^backBolock)(NSDictionary * ); ...@@ -41,6 +41,7 @@ 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)NSString *pickerFontFamily;
@property(strong,nonatomic)NSArray *pickerFontColor; @property(strong,nonatomic)NSArray *pickerFontColor;
@property(strong,nonatomic)NSString *pickerRowHeight; @property(strong,nonatomic)NSString *pickerRowHeight;
...@@ -79,7 +80,7 @@ typedef void(^backBolock)(NSDictionary * ); ...@@ -79,7 +80,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 pickerRowHeight:(NSString *)pickerRowHeight; pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight pickerFontFamily:(NSString *)pickerFontFamily;
-(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 pickerRowHeight:(NSString *)pickerRowHeight pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight pickerFontFamily:(NSString *)pickerFontFamily
{ {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
self.centStr=centerStr; self.centStr=centerStr;
self.pickerToolBarFontSize=pickerToolBarFontSize; self.pickerToolBarFontSize=pickerToolBarFontSize;
self.pickerFontSize=pickerFontSize; self.pickerFontSize=pickerFontSize;
self.pickerFontFamily=pickerFontFamily;
self.pickerFontColor=pickerFontColor; self.pickerFontColor=pickerFontColor;
self.pickerRowHeight=pickerRowHeight; self.pickerRowHeight=pickerRowHeight;
[self getStyle]; [self getStyle];
...@@ -43,46 +44,34 @@ ...@@ -43,46 +44,34 @@
-(void)makeuiWith:(NSArray *)topbgColor With:(NSArray *)bottombgColor With:(NSArray *)leftbtnbgColor With:(NSArray *)rightbtnbgColor With:(NSArray *)centerbtnColor -(void)makeuiWith:(NSArray *)topbgColor With:(NSArray *)bottombgColor With:(NSArray *)leftbtnbgColor With:(NSArray *)rightbtnbgColor With:(NSArray *)centerbtnColor
{ {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0, self.frame.size.width, 40)]; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0, self.frame.size.width, 40)];
view.backgroundColor = [UIColor cyanColor]; view.backgroundColor = [self colorWith:topbgColor];
[self addSubview:view]; [self addSubview:view];
self.leftBtn = [UIButton buttonWithType:UIButtonTypeCustom]; self.leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.leftBtn.frame = CGRectMake(0, 0, 90, 40); self.leftBtn.frame = CGRectMake(0, 0, 90, 40);
self.leftBtn.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerToolBarFontSize integerValue]];
self.leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[self.leftBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 10.0, 0, 0)]; [self.leftBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 10.0, 0, 0)];
[self.leftBtn setTitle:self.leftStr forState:UIControlStateNormal]; [self.leftBtn setTitle:self.leftStr forState:UIControlStateNormal];
[self.leftBtn setFont:[UIFont systemFontOfSize:[_pickerToolBarFontSize integerValue]]];
self.leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[self.leftBtn addTarget:self action:@selector(cancleAction) forControlEvents:UIControlEventTouchUpInside];
[self.leftBtn setTitleColor:[self colorWith:leftbtnbgColor] forState:UIControlStateNormal]; [self.leftBtn setTitleColor:[self colorWith:leftbtnbgColor] forState:UIControlStateNormal];
[self.leftBtn addTarget:self action:@selector(cancleAction) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:self.leftBtn]; [view addSubview:self.leftBtn];
view.backgroundColor=[self colorWith:topbgColor];
self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom]; self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.rightBtn.frame = CGRectMake(view.frame.size.width-90,0, 90, 40); self.rightBtn.frame = CGRectMake(view.frame.size.width-90,0, 90, 40);
self.rightBtn.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerToolBarFontSize integerValue]];
self.rightBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
[self.rightBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10.0)]; [self.rightBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10.0)];
[self.rightBtn setTitle:self.rightStr forState:UIControlStateNormal]; [self.rightBtn setTitle:self.rightStr forState:UIControlStateNormal];
self.rightBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
[self.rightBtn setTitleColor:[self colorWith:rightbtnbgColor] forState:UIControlStateNormal]; [self.rightBtn setTitleColor:[self colorWith:rightbtnbgColor] forState:UIControlStateNormal];
[view addSubview:self.rightBtn];
[self.rightBtn setFont:[UIFont systemFontOfSize:[_pickerToolBarFontSize integerValue]]];
[self.rightBtn addTarget:self action:@selector(cfirmAction) forControlEvents:UIControlEventTouchUpInside]; [self.rightBtn addTarget:self action:@selector(cfirmAction) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:self.rightBtn];
UILabel *cenLabel=[[UILabel alloc]initWithFrame:CGRectMake(90, 5, SCREEN_WIDTH-180, 30)]; UILabel *cenLabel=[[UILabel alloc]initWithFrame:CGRectMake(90, 5, SCREEN_WIDTH-180, 30)];
cenLabel.textAlignment=NSTextAlignmentCenter;
[cenLabel setFont:[UIFont systemFontOfSize:[_pickerToolBarFontSize integerValue]]];
cenLabel.text=self.centStr; cenLabel.text=self.centStr;
cenLabel.textAlignment=NSTextAlignmentCenter;
cenLabel.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerToolBarFontSize integerValue]];
[cenLabel setTextColor:[self colorWith:centerbtnColor]]; [cenLabel setTextColor:[self colorWith:centerbtnColor]];
[view addSubview:cenLabel]; [view addSubview:cenLabel];
self.pick = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, self.frame.size.width, self.frame.size.height - 40)]; self.pick = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, self.frame.size.width, self.frame.size.height - 40)];
...@@ -529,8 +518,9 @@ ...@@ -529,8 +518,9 @@
NSDictionary *dic=[self.dataDry objectAtIndex:i]; NSDictionary *dic=[self.dataDry objectAtIndex:i];
NSArray *ary=[dic allKeys]; NSArray *ary=[dic allKeys];
if ([ary firstObject]) {
[self.provinceArray addObject:[ary firstObject]]; [self.provinceArray addObject:[ary firstObject]];
}
} }
NSDictionary *dic=[self.dataDry firstObject]; NSDictionary *dic=[self.dataDry firstObject];
...@@ -951,8 +941,7 @@ ...@@ -951,8 +941,7 @@
if (lbl == nil) { if (lbl == nil) {
lbl = [[UILabel alloc]init]; lbl = [[UILabel alloc]init];
//在这里设置字体相关属性 lbl.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerFontSize integerValue]];
lbl.font = [UIFont systemFontOfSize:[_pickerFontSize integerValue]];
lbl.textColor = [self colorWith:_pickerFontColor]; lbl.textColor = [self colorWith:_pickerFontColor];
lbl.textAlignment = UITextAlignmentCenter; lbl.textAlignment = UITextAlignmentCenter;
} }
......
...@@ -54,6 +54,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ ...@@ -54,6 +54,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
NSArray *weightArry=indic[@"wheelFlex"]; NSArray *weightArry=indic[@"wheelFlex"];
NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]]; NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]];
NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]]; NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]];
NSString *pickerFontFamily=[NSString stringWithFormat:@"%@",indic[@"pickerFontFamily"]];
NSArray *pickerFontColor=indic[@"pickerFontColor"]; NSArray *pickerFontColor=indic[@"pickerFontColor"];
NSString *pickerRowHeight=indic[@"pickerRowHeight"]; NSString *pickerRowHeight=indic[@"pickerRowHeight"];
id pickerData=indic[@"pickerData"]; id pickerData=indic[@"pickerData"];
...@@ -79,7 +80,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ ...@@ -79,7 +80,7 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
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 pickerRowHeight: pickerRowHeight]; 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 pickerFontFamily:pickerFontFamily];
_pick.bolock=^(NSDictionary *backinfoArry){ _pick.bolock=^(NSDictionary *backinfoArry){
...@@ -121,7 +122,7 @@ RCT_EXPORT_METHOD(hide){ ...@@ -121,7 +122,7 @@ RCT_EXPORT_METHOD(hide){
self.pick.hidden=YES; self.pick.hidden=YES;
return; return;
} }
RCT_EXPORT_METHOD(select: (NSArray*)data){ RCT_EXPORT_METHOD(select: (NSArray*)data){
......
{ {
"name": "react-native-picker", "name": "react-native-picker",
"version": "4.3.6", "version": "4.3.7",
"description": "A Native Picker with high performance.", "description": "A Native Picker with high performance.",
"main": "index.js", "main": "index.js",
"types": "index.d.ts", "types": "index.d.ts",
......
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