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 }
0 commit comments