I am trying to scroll the picker view horizontally and this is my code.
in viewDidLoad I did this,
CGRect frame = horizontalPickerView.frame;
frame.size.width = 50;
frame.size.height = 216;
frame.origin.x=90;
frame.origin.y = 200;
horizontalPickerView.frame = frame;
horizontalPickerView.transform = CGAffineTransformMakeRotation(3.14159/2);
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel *lbl = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 30, 20)] autorelease];
lbl.transform = CGAffineTransformMakeRotation(-3.14159/2);
lbl.text = @"hi";
return lbl;
}
But the problem is I am not able to change the width of picker view more than 216.0 if I try to do this there is a black background left.
CorrectImage http://img709.imageshack.us/img709/6982/picture5g.png this is the correct image
Now if I do this
CGRect frame = horizontalPickerView.frame;
frame.size.width = 50;
frame.size.height = 300;
frame.origin.x=120;
frame.origin.y = 200;
horizontalPickerView.frame = frame;
horizontalPickerView.transform = CGAffineTransformMakeRotation(3.14159/2);
I get this image http://img46.imageshack.us/img46/2792/picture6b.png
I have seen the apps like Seelibrity in which the picker has the width to fit the screen.
Please help me to get out of this problem?
UIPickerView is very sensitive to changes in height, so directly altering its frame or applying a transform to the UIPickerView leads to rendering artifacts. The only reliable way that I know of for resizing a UIPickerView is to place it within a transparent UIView, then apply a scaling (and rotation, in your case) transform to that holder view.
I provide an example of this in this answer.