0

I am trying to include a UIPickerView in a view controller. I am using the following piece of code to reduce the picker view height:

CGAffineTransform t0 = CGAffineTransformMakeTranslation (0, self.room_picker.bounds.size.height/4);
CGAffineTransform s0 = CGAffineTransformMakeScale       (1.0, 0.5);
CGAffineTransform t1 = CGAffineTransformMakeTranslation (0, self.room_picker.bounds.size.height/4);
self.room_picker.transform = CGAffineTransformConcat          (t0, CGAffineTransformConcat(s0, t1));

That works fine, but I am not able to apply the picker view position using AutoLayout. I need to show the picker view just below a UITextField. I am defining the top space to the UITextField to 10. But the result is different. Here you have a screenshot from the iPhone 4s simulator and from the iPhone 5 simulator:

enter image description here enter image description here

How can I get the picker view appear just below the category textfield?

mvasco
  • 4,965
  • 7
  • 59
  • 120

1 Answers1

0

I have been searching and found a solution. This code solves my issue:

    CGAffineTransform t0 = CGAffineTransformMakeTranslation (0, room_picker.bounds.size.height/2);
    CGAffineTransform s0 = CGAffineTransformMakeScale       (1.0, 0.5);
    CGAffineTransform t1 = CGAffineTransformMakeTranslation (0, -room_picker.bounds.size.height/2);
    room_picker.transform = CGAffineTransformConcat          (t0, CGAffineTransformConcat(s0, t1));

The above code change the height of picker view to half and re-position it to the exact (Left-x1, Top-y1) position. Thanks to UIPickerView Height not changeable

Community
  • 1
  • 1
mvasco
  • 4,965
  • 7
  • 59
  • 120