views:

55

answers:

1

I have been working on a horizontal UIPicker, and I've finally gotten the picker and the labels on the picker to both display rotated. But, the issue I'm noticing now is that the labels display in low res with very visible pixelation. Playing with the font values seems to have no effect on the pixelation. I've included my code:

//in view did load...

    [super viewDidLoad];
    myPicker.delegate = self;
    myPicker.dataSource = self;
    myPicker.showsSelectionIndicator =YES;
    myPicker.backgroundColor = [UIColor blackColor];

    CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14/2);

    //original settings
    //rotate = CGAffineTransformScale(rotate, 0.1, 0.8);

    rotate = CGAffineTransformScale(rotate, 0.2, 1.65);
    [self.myPicker setTransform:rotate];    

    NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:@"155", @"165", @"175", 
                      @"185", @"195", @"205", @"215", nil];
    self.pickerData = array; 
    [array release];

    NSInteger TOTALITEM = [pickerData count];

    UILabel *theview[TOTALITEM-1]; // + 1 for the nil
    for (int i=1;i<=TOTALITEM-1;i++) {  
     theview[i] = [[UILabel alloc] init];
     theview[i].text = [NSString stringWithFormat:@"%d",i];
     theview[i].textColor = [UIColor blackColor];
     theview[i].frame = CGRectMake(0,0, 25, 25);
     theview[i].backgroundColor = [UIColor clearColor];
     theview[i].textAlignment = UITextAlignmentCenter;
     theview[i].shadowColor = [UIColor whiteColor];
     theview[i].shadowOffset = CGSizeMake(-1,-1);
     theview[i].adjustsFontSizeToFitWidth = NO;

     UIFont *myFont = [UIFont fontWithName:@"Helvetica" size:10];
     [theview[i] setFont:myFont];
    }


    CGAffineTransform rotateItem = CGAffineTransformMakeRotation(-3.14/2);
    rotateItem = CGAffineTransformScale(rotateItem, 1, 10);

    for (int j=1;j<=TOTALITEM-1;j++) { 
        theview[j].transform = rotateItem;

    }

 pickerData = [[NSMutableArray alloc] init];


 for (int j=1;j<=TOTALITEM-1;j++) { 

     [pickerData addObject:theview[j]];

  }
A: 

I found the issue, so I thought I would post the answer here. It's obvious now. I was using the same scale transform settings on the text as the UIPicker. To fix it I reduced the transform on the text by 50% and used the font size to control the size of the labels. Here's the code I changed:

Original:

 UIFont *myFont = [UIFont fontWithName:@"Helvetica" size:10];
 [theview[i] setFont:myFont];
}


CGAffineTransform rotateItem = CGAffineTransformMakeRotation(-3.14/2);
rotateItem = CGAffineTransformScale(rotateItem, 1, 10);

Fixed:

 UIFont *myFont = [UIFont fontWithName:@"Helvetica" size:30];
 [theview[i] setFont:myFont];
}


CGAffineTransform rotateItem = CGAffineTransformMakeRotation(-3.14/2);
rotateItem = CGAffineTransformScale(rotateItem, .5, 5);
Jeremy