Skip to content

Commit 6af175d

Browse files
committed
new feature pickerFontFamily for both android and ios
1 parent 0e39dea commit 6af175d

File tree

6 files changed

+23
-32
lines changed

6 files changed

+23
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
|wheelFlex | array | [1, 1, 1] | iOS/Android | |
2626
|pickerFontSize | number | 16 | iOS/Android | |
2727
|pickerFontColor | array | [31, 31, 31, 1] | iOS/Android | |
28-
|pickerFontFamily | string | | Android | |
28+
|pickerFontFamily | string | | iOS/Android | |
2929
|pickerRowHeight | number | 24 | iOS | |
3030
|pickerData | array | | iOS/Android | |
3131
|selectedValue | array | | iOS/Android | |

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ interface PickerOptions {
6060
* @type {string}
6161
* @memberof PickerOptions
6262
*/
63-
pickerCancelBtnText: string
63+
pickerCancelBtnText?: string
6464

6565
/**
6666
* The color of the text for the confirm button

ios/RCTBEEPickerManager/BzwPicker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef void(^backBolock)(NSDictionary * );
4141
@property(strong,nonatomic)NSString *rightStr;
4242
@property(strong,nonatomic)NSString *pickerToolBarFontSize;
4343
@property(strong,nonatomic)NSString *pickerFontSize;
44+
@property(strong,nonatomic)NSString *pickerFontFamily;
4445
@property(strong,nonatomic)NSArray *pickerFontColor;
4546
@property(strong,nonatomic)NSString *pickerRowHeight;
4647

@@ -79,7 +80,7 @@ typedef void(^backBolock)(NSDictionary * );
7980

8081

8182
-(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
82-
pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight;
83+
pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight pickerFontFamily:(NSString *)pickerFontFamily;
8384

8485
-(void)selectRow;
8586
@end

ios/RCTBEEPickerManager/BzwPicker.m

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@implementation BzwPicker
1313

1414
-(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
15-
pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight
15+
pickerToolBarFontSize:(NSString *)pickerToolBarFontSize pickerFontSize:(NSString *)pickerFontSize pickerFontColor:(NSArray *)pickerFontColor pickerRowHeight:(NSString *)pickerRowHeight pickerFontFamily:(NSString *)pickerFontFamily
1616

1717
{
1818
self = [super initWithFrame:frame];
@@ -29,6 +29,7 @@ -(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSSt
2929
self.centStr=centerStr;
3030
self.pickerToolBarFontSize=pickerToolBarFontSize;
3131
self.pickerFontSize=pickerFontSize;
32+
self.pickerFontFamily=pickerFontFamily;
3233
self.pickerFontColor=pickerFontColor;
3334
self.pickerRowHeight=pickerRowHeight;
3435
[self getStyle];
@@ -43,46 +44,34 @@ -(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSSt
4344
-(void)makeuiWith:(NSArray *)topbgColor With:(NSArray *)bottombgColor With:(NSArray *)leftbtnbgColor With:(NSArray *)rightbtnbgColor With:(NSArray *)centerbtnColor
4445
{
4546
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0, self.frame.size.width, 40)];
46-
view.backgroundColor = [UIColor cyanColor];
47-
47+
view.backgroundColor = [self colorWith:topbgColor];
4848
[self addSubview:view];
4949

5050
self.leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
5151
self.leftBtn.frame = CGRectMake(0, 0, 90, 40);
52+
self.leftBtn.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerToolBarFontSize integerValue]];
53+
self.leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
5254
[self.leftBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 10.0, 0, 0)];
5355
[self.leftBtn setTitle:self.leftStr forState:UIControlStateNormal];
54-
[self.leftBtn setFont:[UIFont systemFontOfSize:[_pickerToolBarFontSize integerValue]]];
55-
self.leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
56-
[self.leftBtn addTarget:self action:@selector(cancleAction) forControlEvents:UIControlEventTouchUpInside];
57-
5856
[self.leftBtn setTitleColor:[self colorWith:leftbtnbgColor] forState:UIControlStateNormal];
59-
57+
[self.leftBtn addTarget:self action:@selector(cancleAction) forControlEvents:UIControlEventTouchUpInside];
6058
[view addSubview:self.leftBtn];
6159

62-
view.backgroundColor=[self colorWith:topbgColor];
63-
6460
self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
6561
self.rightBtn.frame = CGRectMake(view.frame.size.width-90,0, 90, 40);
62+
self.rightBtn.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerToolBarFontSize integerValue]];
63+
self.rightBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
6664
[self.rightBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10.0)];
6765
[self.rightBtn setTitle:self.rightStr forState:UIControlStateNormal];
68-
self.rightBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
69-
7066
[self.rightBtn setTitleColor:[self colorWith:rightbtnbgColor] forState:UIControlStateNormal];
71-
72-
[view addSubview:self.rightBtn];
73-
[self.rightBtn setFont:[UIFont systemFontOfSize:[_pickerToolBarFontSize integerValue]]];
7467
[self.rightBtn addTarget:self action:@selector(cfirmAction) forControlEvents:UIControlEventTouchUpInside];
68+
[view addSubview:self.rightBtn];
7569

7670
UILabel *cenLabel=[[UILabel alloc]initWithFrame:CGRectMake(90, 5, SCREEN_WIDTH-180, 30)];
77-
78-
cenLabel.textAlignment=NSTextAlignmentCenter;
79-
80-
[cenLabel setFont:[UIFont systemFontOfSize:[_pickerToolBarFontSize integerValue]]];
81-
8271
cenLabel.text=self.centStr;
83-
72+
cenLabel.textAlignment=NSTextAlignmentCenter;
73+
cenLabel.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerToolBarFontSize integerValue]];
8474
[cenLabel setTextColor:[self colorWith:centerbtnColor]];
85-
8675
[view addSubview:cenLabel];
8776

8877
self.pick = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, self.frame.size.width, self.frame.size.height - 40)];
@@ -529,8 +518,9 @@ -(void)getnumStyle{
529518
NSDictionary *dic=[self.dataDry objectAtIndex:i];
530519

531520
NSArray *ary=[dic allKeys];
532-
533-
[self.provinceArray addObject:[ary firstObject]];
521+
if ([ary firstObject]) {
522+
[self.provinceArray addObject:[ary firstObject]];
523+
}
534524
}
535525

536526
NSDictionary *dic=[self.dataDry firstObject];
@@ -951,8 +941,7 @@ -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forCo
951941

952942
if (lbl == nil) {
953943
lbl = [[UILabel alloc]init];
954-
//在这里设置字体相关属性
955-
lbl.font = [UIFont systemFontOfSize:[_pickerFontSize integerValue]];
944+
lbl.font = [UIFont fontWithName:_pickerFontFamily size:[_pickerFontSize integerValue]];
956945
lbl.textColor = [self colorWith:_pickerFontColor];
957946
lbl.textAlignment = UITextAlignmentCenter;
958947
}

ios/RCTBEEPickerManager/RCTBEEPickerManager.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ + (BOOL)requiresMainQueueSetup
5454
NSArray *weightArry=indic[@"wheelFlex"];
5555
NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]];
5656
NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]];
57+
NSString *pickerFontFamily=[NSString stringWithFormat:@"%@",indic[@"pickerFontFamily"]];
5758
NSArray *pickerFontColor=indic[@"pickerFontColor"];
5859
NSString *pickerRowHeight=indic[@"pickerRowHeight"];
5960
id pickerData=indic[@"pickerData"];
@@ -79,7 +80,7 @@ + (BOOL)requiresMainQueueSetup
7980
self.height=220;
8081
}
8182

82-
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];
83+
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];
8384

8485
_pick.bolock=^(NSDictionary *backinfoArry){
8586

@@ -121,7 +122,7 @@ + (BOOL)requiresMainQueueSetup
121122

122123
self.pick.hidden=YES;
123124

124-
return;
125+
return;
125126
}
126127

127128
RCT_EXPORT_METHOD(select: (NSArray*)data){

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-picker",
3-
"version": "4.3.6",
3+
"version": "4.3.7",
44
"description": "A Native Picker with high performance.",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)