Reputation: 337
I have a problem regarding on how to set the height of UIPickerView
.
I have a code in setting the width.
This,
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
return 280;
}
Looks fine,
But how i Can change the height? I am new to iOS. please help me.
EDIT
I have done something like this.
CGAffineTransform s0 = CGAffineTransformMakeScale(1, 0.7);
CGAffineTransform t1 = CGAffineTransformMakeTranslation(0,0);
picker.transform = CGAffineTransformConcat(s0, t1);
But it squishes the UIPickerView
. Is there any better way to do this?
Upvotes: 2
Views: 1641
Reputation: 31081
You can set your pickerView frame through coding. There are only three valid heights for UIPickerView
162, 180 and 216.
CGRect newframe=pickerView.frame;
frame.size.height=162/180/216;
[pickerView setFrame:newframe];
Upvotes: 1
Reputation: 91
set pickerview height to minumum possible i.e 162 then use
UIPickerView *pickView=[[UIPickerView alloc]initWithFrame:CGRectMake(50, 50, 334, 162)]; CGAffineTransform t0 = CGAffineTransformMakeTranslation (0,pickView.bounds.size.height/2);
CGAffineTransform s0 = CGAffineTransformMakeScale (0.6, 0.6);
CGAffineTransform t1 = CGAffineTransformMakeTranslation (0,-pickView.bounds.size.height/2);
pickView.transform = CGAffineTransformConcat(t0, CGAffineTransformConcat(s0, t1));
adjust the width accordingly to have minimum shrinkness.. Hope this will help you.
Upvotes: 0
Reputation: 198
There are only three valid heights for UIPickerView 162, 180 and 216.
Upvotes: 1