use below statement to make picker horizontal:
picker.transform =
CGAffineTransformMakeRotation(M_PI+M_PI_2);
picker.frame = CGRectMake(80,10 ,150,44);
Delegate and Data source function of picker:
- (UIView
*)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc]
initWithFrame:CGRectMake(0, 0, 150, 20)];
label.text = @"miles";
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor blackColor];
label.font = [UIFont systemFontOfSize:13];
label.backgroundColor = [UIColor clearColor];
label.opaque = NO;
CGAffineTransform rotate =
CGAffineTransformMakeRotation(1.57);
[label setTransform:rotate];
return label;
}
-
(CGFloat)pickerView:(UIPickerView *)pickerView
widthForComponent:(NSInteger)component
{
return 30;
}
-
(CGFloat)pickerView:(UIPickerView *)pickerView
rowHeightForComponent:(NSInteger)component
{
return 80;
}
No comments:
Post a Comment