12
12
@implementation BzwPicker
13
13
14
14
-(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
16
16
17
17
{
18
18
self = [super initWithFrame: frame];
@@ -29,6 +29,7 @@ -(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSSt
29
29
self.centStr =centerStr;
30
30
self.pickerToolBarFontSize =pickerToolBarFontSize;
31
31
self.pickerFontSize =pickerFontSize;
32
+ self.pickerFontFamily =pickerFontFamily;
32
33
self.pickerFontColor =pickerFontColor;
33
34
self.pickerRowHeight =pickerRowHeight;
34
35
[self getStyle ];
@@ -43,46 +44,34 @@ -(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSSt
43
44
-(void )makeuiWith : (NSArray *)topbgColor With : (NSArray *)bottombgColor With : (NSArray *)leftbtnbgColor With : (NSArray *)rightbtnbgColor With : (NSArray *)centerbtnColor
44
45
{
45
46
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];
48
48
[self addSubview: view];
49
49
50
50
self.leftBtn = [UIButton buttonWithType: UIButtonTypeCustom];
51
51
self.leftBtn .frame = CGRectMake (0 , 0 , 90 , 40 );
52
+ self.leftBtn .font = [UIFont fontWithName: _pickerFontFamily size: [_pickerToolBarFontSize integerValue ]];
53
+ self.leftBtn .contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
52
54
[self .leftBtn setTitleEdgeInsets: UIEdgeInsetsMake (0 , 10.0 , 0 , 0 )];
53
55
[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
-
58
56
[self .leftBtn setTitleColor: [self colorWith: leftbtnbgColor] forState: UIControlStateNormal];
59
-
57
+ [ self .leftBtn addTarget: self action: @selector ( cancleAction ) forControlEvents: UIControlEventTouchUpInside];
60
58
[view addSubview: self .leftBtn];
61
59
62
- view.backgroundColor =[self colorWith: topbgColor];
63
-
64
60
self.rightBtn = [UIButton buttonWithType: UIButtonTypeCustom];
65
61
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;
66
64
[self .rightBtn setTitleEdgeInsets: UIEdgeInsetsMake (0 , 0 , 0 , 10.0 )];
67
65
[self .rightBtn setTitle: self .rightStr forState: UIControlStateNormal];
68
- self.rightBtn .contentHorizontalAlignment =UIControlContentHorizontalAlignmentRight;
69
-
70
66
[self .rightBtn setTitleColor: [self colorWith: rightbtnbgColor] forState: UIControlStateNormal];
71
-
72
- [view addSubview: self .rightBtn];
73
- [self .rightBtn setFont: [UIFont systemFontOfSize: [_pickerToolBarFontSize integerValue ]]];
74
67
[self .rightBtn addTarget: self action: @selector (cfirmAction ) forControlEvents: UIControlEventTouchUpInside];
68
+ [view addSubview: self .rightBtn];
75
69
76
70
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
-
82
71
cenLabel.text =self.centStr ;
83
-
72
+ cenLabel.textAlignment =NSTextAlignmentCenter;
73
+ cenLabel.font = [UIFont fontWithName: _pickerFontFamily size: [_pickerToolBarFontSize integerValue ]];
84
74
[cenLabel setTextColor: [self colorWith: centerbtnColor]];
85
-
86
75
[view addSubview: cenLabel];
87
76
88
77
self.pick = [[UIPickerView alloc ] initWithFrame: CGRectMake (0 , 40 , self .frame.size.width, self .frame.size.height - 40 )];
@@ -529,8 +518,9 @@ -(void)getnumStyle{
529
518
NSDictionary *dic=[self .dataDry objectAtIndex: i];
530
519
531
520
NSArray *ary=[dic allKeys ];
532
-
533
- [self .provinceArray addObject: [ary firstObject ]];
521
+ if ([ary firstObject ]) {
522
+ [self .provinceArray addObject: [ary firstObject ]];
523
+ }
534
524
}
535
525
536
526
NSDictionary *dic=[self .dataDry firstObject ];
@@ -951,8 +941,7 @@ -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forCo
951
941
952
942
if (lbl == nil ) {
953
943
lbl = [[UILabel alloc ]init];
954
- // 在这里设置字体相关属性
955
- lbl.font = [UIFont systemFontOfSize: [_pickerFontSize integerValue ]];
944
+ lbl.font = [UIFont fontWithName: _pickerFontFamily size: [_pickerFontSize integerValue ]];
956
945
lbl.textColor = [self colorWith: _pickerFontColor];
957
946
lbl.textAlignment = UITextAlignmentCenter;
958
947
}
0 commit comments