How to adjust the height of UIPickerView
How to set the UIPickerView height more than 250. i did the following but couldn't get the height as stated
-(void)pickerview:(id)sender
{
pickerView=[[UIPickerView alloc] initWithFrame:CGRectMake(0,200,320,400)];
pickerView.transform = CGAffineTransformMakeScale(0.75f, 0.75f);
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.showsSelectionIndicator = YES;
pickerView.backgroundColor = [UIColor lightGrayColor];
[pickerView selectRow:1 inComponent:0 animated:YES];
[self.view addSubview:pickerView];
// [contentView addSubview:pickerView];
}
+3
source to share
1 answer
There are only three valid heights for the UIPickerView (162.0, 180.0 and 216.0).
You can use the CGAffineTransformMakeTranslation and CGAffineTransformMakeScale functions to select the correct picker for convenience.
Example:
CGAffineTransform t0 = CGAffineTransformMakeTranslation( 0,
pickerview.bounds.size.height/2 );
CGAffineTransform s0 = CGAffineTransformMakeScale(1.0, 0.5);
CGAffineTransform t1 = CGAffineTransformMakeTranslation( 0,
pickerview.bounds.size.height/-2 );
pickerview.transform = CGAffineTransformConcat( t0,
CGAffineTransformConcat(s0, t1) );
The above code changes the height of the picker view by half and rearranges it to the exact position (Left-x1, Top-y1).
See here for details. How to change the height of UIPickerView
+7
source to share