iOS 14: Changes in the UIDatePicker
Let's take a look at how the release of iOS 14 changed the UIDatePicker.
Some time ago I wrote about the changes in iOS 14 UISearchBar. But these are not all the differences between Apple's last mobile OS version and the previous ones. This time I would like to focus on the changes in UIDatePicker - a module responsible for picking dates in your app.
Pickers in ios14
In iOS we can find two types of pickers - UIPickerView and UIDatePicker. Whilst the first one is for the general purposes, the second one is only for dates & hours. Although through its entire career the Date Picker underwent a number of changes, the latest are more important than ever.
Previously UIDatePicker was based on scrolling dates. But in iOS 14 preferredDatePickerStyle appeared. It lets you choose the style - no only the well-known wheel from previous versions, but also:
- automatic
- inline
- compact.
Let's take a closer look at them.
The UIDatePicker automatic style
This style leaves determining the style to the system. IOS 14 will choose the best look for your Date Picker while launching your app. This one can be an option if you don't care how your picker should look.
The UIDatePicker inline style
This is the biggest view for UIDatePicker. It shows the whole month with a selected date. And below it you can check the hour or pick it. The best option, if you want your users to have the easiest access to dates in the app.
UIDatePicker compact style
In this option, the UIDatePicker shows only a short version of date & time. But on the user’s tap, a bigger view is shown. Similarly to the inline style, you can pick the date or type the hour on a keyboard. It also has many other well-known functionalities.
Conclusion
If you have any Date Pickers in your app, and your app is ready for at least iOS 13 - beware. You should check, how the new UIDatePicker looks and behaves. There are more options to choose. And at last, but not least - besides preferredDatePickerStyle appeared also datePickerStyle. This one has only the get property, so don't be confused. And datePickerStyle returns a concrete style, never the automatic one.