BCHPickerView
功能介紹
基于UIPickerView控件封裝的簡(jiǎn)單易用k的控件;只需要一個(gè)api就能實(shí)現(xiàn)功能,避免以往麻煩冗余的代碼.選擇數(shù)據(jù)之后會(huì)以block回調(diào)的形式得到數(shù)據(jù).
用法
使用
支持iOS8.0以上
pod 'BCHPickerView'
1.默認(rèn)實(shí)現(xiàn)效果
代碼:
[BCHPickerView bch_PickerViewInView:self.view
items:self.items
options:@{BCHSelectedObject:self.selectedValue}
completion:^(BCHPickerView *view, NSInteger selectedIndex, NSString *selectedValue) {
self.selectedValue = selectedValue;
}];
效果:
2.自定義效果(傳一個(gè)字典即可)
代碼:
[BCHPickerView bch_PickerViewInView:self.view
items:self.items
options:@{
BCHItemHeight:@"35",
BCHToolBarHeight:@"35",
BCHButtonFont:[UIFont systemFontOfSize:15],
BCHButtonTextColor:[UIColor colorWithRed:51/255.0 green:219 /255.0 blue:172/255.0 alpha:1.0],
BCHBackgroundColor: [UIColor blueColor],
BCHToolBarBackgroundColor:[UIColor redColor],
BCHToolBarTopBorderColor:[UIColor groupTableViewBackgroundColor],
BCHToolBarBottomBorderColor:[UIColor groupTableViewBackgroundColor],
BCHSelectedObject:self.selectedValue,
BCHItemBackgroundColor:[UIColor orangeColor],
BCHTextColor:[UIColor cyanColor],
BCHTextFont:[UIFont systemFontOfSize:20],
}
completion:^(BCHPickerView *view, NSInteger selectedIndex, NSString *selectedValue) {
NSLog(@"view:%@",view);
NSLog(@"selectedIndex:%ld",selectedIndex);
NSLog(@"selectedValue:%@",selectedValue);
self.selectedValue = selectedValue;
}];
效果: