Będziesz musiał zaprogramować selektor, dzięki czemu będziesz mógł stworzyć własny sorter o rozmiarze CGRectMake(x, y, width, height)
, wtedy będziesz musiał go obrócić, ale obracanie będzie również obracać w metodach Picker's dataSources, będziesz musiał obrócić widok odwrotność rotacji oknie wyboru, jestem w tym kodzie hopfully pomoże
.....
...
...
NSArray *arr = [NSArray arrayWithObjects:@"1 mi", @"2 mi", @"5 mi", @"10 mi", @"15 mi", @"20 mi", @"25 mi",
@"30 mi", @"35 mi", @"40 mi", @"45 mi", @"50 mi", @"75 mi", @"99 mi", nil];
radiusDefaults = [[NSMutableArray alloc] initWithArray:arr] ;
radiusPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 100, 150)];
radiusPicker.delegate = self;
radiusPicker.dataSource = self;
radiusPicker.showsSelectionIndicator = NO;
//Resize the picker, rotate it so that it is horizontal and set its position
CGAffineTransform rotate = CGAffineTransformMakeRotation(-1.57);
rotate = CGAffineTransformScale(rotate, .1, .5);
CGAffineTransform t0 = CGAffineTransformMakeTranslation(-61, 0);
radiusPicker.transform = CGAffineTransformConcat(rotate,t0);
// [theNavigationBar.topItem setTitleView:radiusPicker] ;
UIView *pickerWrapper = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 215)];
[self.view addSubview:radiusPicker];
[radiusPicker selectRow:6 inComponent:0 animated:NO];
[radiusPicker release];
.....
.......
....
#pragma mark -
#pragma mark UIPickerView
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view{
UIView *viewForRow = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 400)] autorelease];
UILabel *label;
UIFont *font = [ UIFont fontWithName:@"ArialRoundedMTBold" size:22];
label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 20, 70, 350)] autorelease];
[label setText:[NSString stringWithFormat:@"%@", [radiusDefaults objectAtIndex:row]]];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor blueColor];
label.font = font;
label.backgroundColor = [UIColor clearColor];
// label.opaque = NO;
[viewForRow addSubview:label];
CGAffineTransform rotate = CGAffineTransformMakeRotation(1.57);
rotate = CGAffineTransformScale(rotate, 1, 6.5);
[viewForRow setTransform:rotate];
return viewForRow;
}
Oto, jak powinien wyglądać pricker: http://images.macworld.com/images/reviews/graphics/143531-dr_dof_original.jpg – Donna