ios自带的UIDataPicker和UIDatePicker最大的毛病就是没有带确定和取消这两个按钮,而ActionSheetPicker是以上两个选择器的开源封装。但是这个东东也有些小问题,就是没有汉化选择器的内容。
原始的ActionSheetPicker运行起来是这个样子的:
改进后是这以下这个样子的
点击此处下载,有问题可加扣扣359709421讨论。
补充一个缺陷的修复,在ios7以上版本中,选择器数据部份是透明的,很不美观,
把AbstractActionSheetPicker.m的showActionSheetPicker方法加上一行
masterView.backgroundColor=[UIColor whiteColor];
即可以解决此问题。
Java代码
- - (void)showActionSheetPicker {
- UIView *masterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.viewSize.width, 260)];
- UIToolbar *pickerToolbar = [self createPickerToolbarWithTitle:self.title];
- [pickerToolbar setBarStyle:UIBarStyleBlackTranslucent];
- [masterView addSubview:pickerToolbar];
- self.pickerView = [self configuredPickerView];
- NSAssert(_pickerView != NULL, @"Picker view failed to instantiate, perhaps you have invalid component data.");
- [masterView addSubview:_pickerView];
- masterView.backgroundColor=[UIColor whiteColor];
- [self presentPickerForView:masterView];
- }
- (void)showActionSheetPicker { UIView *masterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.viewSize.width, 260)]; UIToolbar *pickerToolbar = [self createPickerToolbarWithTitle:self.title]; [pickerToolbar setBarStyle:UIBarStyleBlackTranslucent]; [masterView addSubview:pickerToolbar]; self.pickerView = [self configuredPickerView]; NSAssert(_pickerView != NULL, @"Picker view failed to instantiate, perhaps you have invalid component data."); [masterView addSubview:_pickerView]; masterView.backgroundColor=[UIColor whiteColor]; [self presentPickerForView:masterView]; }
我的网店,有劳各位参观参观 http://mrs-x.taobao.com/
- 大小: 256.1 KB
- 大小: 221.6 KB
时间: 2024-11-15 00:28:28