79689583

Date: 2025-07-04 00:49:42
Score: 1
Natty:
Report link

In the on change handler of whatever you're hooking up the DatePicker with, do this:

[datePicker setNeedsLayout];
[datePicker layoutIfNeeded];
CGFloat width = [datePicker systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].width;

The first two lines are needed in order for it to be the latest size and not from before the change.

Credits: developer.apple.com/forums/thread/790220

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: John