I would like to reduce the height of a UIPickerView
in my iPhone app, so that it shows only one row and one column. The height of the picker view should be equal to the height of a row.
I'm using Interface Builder to construct the UIPickerView
, but I can't find an easy way to re-size this control.
How do you shrink a UIPickerView
?
Actually, you can slightly shrink the whole UIPickerView by applying an affine transform to an enclosing view. For example:
CGSize pickerSize = [pickerView sizeThatFits:CGSizeZero]; pickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, pickerSize.width, pickerSize.height)]; pickerTransformView.transform = CGAffineTransformMakeScale(0.75f, 0.75f); [pickerTransformView addSubview:pickerView]; [self.view addSubview:pickerTransformView]; [pickerTransformView release];
will scale a picker to 75% of its original size by placing it within a containing view and applying a scaling transform to that view. Applying a transform directly to the UIPickerView leads to undesirable drawing artifacts.
However, the kind of resizing you're looking for would be best served by creating a custom control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With