rotated (horizontal) picker

Discussion in 'iOS Programming' started by ella.paula, Apr 19, 2010.

  1. ella.paula macrumors newbie

    Apr 19, 2010

    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:
    	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

    -(UIView *) pickerView:(UIPickerView *)pickerView 
    			viewForRow:(NSInteger) row
    		    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

    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
    b) it would probably offend the Apple rules.

    Thanks in advance for your response.
  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    ... as would discussing 4.0 here since it's still under the NDA. ;)

Share This Page