UIDatePicker getting cut

557 views Asked by At

I added UIDatePicker to the UI and gave proper leading and trailing margins. Somehow, a part of W in Wednesday and part of M in Monday are getting cut.

Attached images. I tried increasing and decreasing leading distance from superview but no luck. Can anyone please point me in the right direction?

2

There are 2 answers

1
dahiya_boy On BEST ANSWER

If we talk about Date Picker, whenever the date with Mon/Wed is selected it is does not get proper space to show the complete info of that particular date. I just try the something with DatePicker.

  1. If datePicker have complete width, then it does not cut 'M' or 'W'.
  2. If i diminished the width after certain level it starts cutting little portion of 'M' or 'W' and inter space between components is manageable automatically by x-code, Now I rotate the simulator, datePicker is working properly because my constraints is according to width of the simulator as it rotated in landscape datepicker get wider.

Suggestion for your problem : Give DatePicker appropriate width otherwise it behaves like this always.

0
Leszek Szary On

Unfortunately UIDatePicker does not handle change of the width properly and it always cut Wed and Mon words if the width is less than 320. If you really need to make the width lower than 320 you can solve this with CGAffineTransform. You need to keep the width set to 320 and use transform property to change the scale of the view:

self.transform = CGAffineTransformMakeScale(280.0 / 320.0, 280.0 / 320.0);

This will make the UIDatePicker smaller and it won't cut anything.