Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ella.paula

macrumors newbie
Original poster
Apr 19, 2010
1
0
Hi,

for some specific GUI I had to create a "horizontal picker".
I realized this by rotating a normal UIPicker using CGAffineTransformRotate and changing the values of the frame property to adjust the border elemts of the picker.

So what I did wasbasically in viewDidLoad:
Code:
	uiPicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
	uiPicker.delegate = self;
	uiPicker.dataSource = self;
	uiPicker.showsSelectionIndicator = YES;
	uiPicker.transform = CGAffineTransformRotate(uiPicker.transform, -M_PI/2);
	uiPicker.frame = CGRectMake(xCoor, yCoor, 180, 40);
	[ viewContainer addSubview:uiPicker];
	[uiPickerForLevel release];

and in pickerView:viewForRow:forComponent:reusingView I do some coding to create a rotatet view

Code:
-(UIView *) pickerView:(UIPickerView *)pickerView 
			viewForRow:(NSInteger) row
			forComponent:(NSInteger)component 
		    reusingView:(UIView *)view {

	UILabel *label;
	UIFont *font = [ UIFont systemFontOfSize:24];
	label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
	label.text = [ self pickerView:pickerView titleForRow:row forComponent:component];
	label.textAlignment = UITextAlignmentCenter;
	label.textColor = [UIColor blackColor];
	label.textAlignment = UITextAlignmentCenter;
	label.font = font;
	label.frame = CGRectMake(0, 0, 
							 [ self pickerView:pickerView widthForComponent:component], 
							 [ self pickerView:pickerView widthForComponent:component]);
	label.backgroundColor = [UIColor clearColor];
	label.opaque = YES;
	
	label.transform = CGAffineTransformRotate(label.transform, M_PI/2);
	return label;
}

By using iPhone OS 3.x I got a (somehow) nice picker looking like this
horizontalPicker.png


But is there a way to get rid of all border elements?
Or even better: is there a documented and official way to manipulate the border elements? Or maybe a customized version of UIPicker providing the requested functionality you want to share?

Btw.: I do not think looping through the children of the UIPicker and removing subviews by "guessing" which is such a border element is a good ideas since
a) as mentioned it would be a guess
and
b) it would probably offend the Apple rules.


Thanks in advance for your response.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.