Member-only story

Introducing Swift’s New Modern Date Picker

A UI component that was long overdue for a refresh just got one

Kelvin Tan
Better Programming
2 min readJul 8, 2020

--

Photo by Eliza Diamond on Unsplash.

As revealed at WWDC 2020, Apple has given the Date and Time Picker an Airbnb-style upgrade. Since there isn’t a new name for this Date Picker, let’s just call it the Modern Date Picker.

“Display a calendar date and provide controls for editing the date value.” — Apple’s documentation

Prerequisites

To follow along with this tutorial, you’ll need some basic knowledge in:

  • Swift
  • At least Xcode 12+

Note: This only supports iOS 14+.

Modern Date Picker

To give you a better picture of the transformation, take one last look at the traditional Date Picker. Now look at the Modern Date Picker with one line of code:

datePicker.preferredDatePickerStyle = .compact

I was wondering how to exit the pop-up once I was done selecting the date and time. I was hoping to see a “Done”…

--

--

Kelvin Tan
Kelvin Tan

Written by Kelvin Tan

Father, husband, software engineer. Building software and building a family, one line of code and one moment at a time. 🚀💻💙 http://ko-fi.com/kelvintanzy

No responses yet

What are your thoughts?