I have a requirement to use date picker in my applicaiton. I have lot of controlles in my view that..i cannot add the date picker with the default size. Can anyone please suggest me that how can I reduce the size of the picker? i tried it with Ib, but size option is disabled in IB?
You can change the size of your datepicker with changing the frame of the DatepIcker, but this will clip most of the datepicker and is not a good idea. Try to add your datepicker in a modal view instead.
If you create UIPickerView
in your code then you can use -initWithFrame
to set its frame explicitly (see this question) - in the answer provided there stated that some "visual glitches" may appear with this approach.
As a second option you can adjust picker's frame by applying appropriate CGAffineTransform
to it ( I have not tested it much but it seems to work fine):
picker.transform = CGAffineTransformMake(0.5, 0, 0, 0.5, -80, 0);
This (somewhat dummy) code scales UIPickerView to a half size and applies translation to place the picker to the left side of the screen. You can play with different transform values to get the effect you want.
Edit: The code above works for UIDatePickerView
as well (sorry was not attentive to a question). But as other stated Apple had not made picker's frame (easily) customizable so it may mean that you should consider changing your design to try to use the picker in its proper size to conform to Apple's HIG.
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