SwiftUI - DatePicker Tutorial
HTML-код
- Опубликовано: 7 фев 2025
- In today's video I show you how to use the new date picker in SwiftUI and iOS 14. I discuss how to use basic date ranges, display components and styles.
SwiftUI DatePicker Documentation:
developer.appl...
If you like my teaching or presentation style, I've started creating my own courses:
seanallen.teac...
Twitter:
/ seanallen_dev
Link to my book - How I Became an iOS Developer:
gumroad.com/l/...
Hired.com:
hired.com/x/1n01g
Check out my podcast, iOS Dev Discussions:
itunes.apple.c...
Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
Ray Wenderlich Books:
store.raywende...
Ray Wenderlich Videos:
store.raywende...
Paul Hudson's Hacking With Swift:
gumroad.com/a/...
Learn Advanced Swift Here:
gumroad.com/a/...
Links to my iOS Dev Setup & iOS Dev Book Recommendations
www.amazon.com...
#swift #softwaredeveloper #iosdeveloper
If you enjoy my teaching/presentation style, I've started creating my own iOS development courses at seanallen.teachable.com. You can watch the first ~10% of each course for free to get a feel for them.
Sean! This is my first time coming across your channel. Today, I've watched about 5 different videos on Swift. Yours? Best one by far!
I'm a beginner. Your cadence is perfect. You don't have any filler words. You seem warm and friendly. I didn't feel stupid watching your lesson. And you don't try to speed through like so many coders do. Oh-and you were so thorough about the whole thing! Really, really dig your teaching style man!
PS: I skipped back just to grab the link to your teaching site. (I *never* do that for other vids.)
Thanks for the kind words. Happy to hear you enjoy my teaching style!
Thank you Sean! Just what I was looking for 🤯
Happy to help!
I would like to see tutorial how to create iOS 14 widgets for existing uikit projects
Always helpful! Thanks, Sean!
No problem, David.
Great video as usual.
Thanks!
Simple tutorial, yet it has powerful details. Thanks .
I am so hoping you make Combine tutorial about URLSessions , and diff usages
I still need more practice with Combine, myself. I'll get there in time.
@@seanallen waiting for the quality content by you ✌️😬
Long overdue from Apple to ship some calendar component. I wish that it’s less buggy and does not throw bunch of broken constraint warnings in Xcode console ;)
Wow. So much easier than Objective-C. Great job.
Thanks 😀
I love the new date picker for SwiftUI, was about time to improve this feature that Android has long time ago.
Agreed.
Thank you! :)
You're welcome!
This is plain awesome! 🤩 Thank you Sean!
You bet!
Damn this component is so beautiful 😍
It's a huge improvement.
Great video Sean. I wonder if the date picker has an option to return nil? I would like to use it in case my model date is optional, for example I don’t know a birthday or an appointment date etc.
Can we only pick the months and years?
OK How would we isolate the month part of the date in SwiftUI
Thank you for knowledge
Happy to help, Vorapon
Great job Sean... I love the way you explain things.. Can you just select a month only ?? Cheers... Craig
hello! Thank you for your lessons
I have a question, how can i close datePicker after i tap and pick a date.?
I don't like that there is no Done button once the date picker is expanded. Users just don't understand that they need to tap outside on the screen. Do you know a solution for this?
I agree. As far as I know, the user needs to tap outside the date picker to dismiss it. I'm not aware of a "done" button type solution.
I don't think DatePicker has anything like an accessoryView, even in UIKit. The only way I can think of is hijacking the tap on the compact DatePicker view, and opening a custom view with a button and a Graphical DatePicker. I can try and put an example together if you'd like, although it's a big hack and you probably want to stick with the default behaviour.
what if I want my date picker to popup
Thanks good info, good style in putting it across well explained, just thought today need a date on my app just wondering if it will update daily or is that something else I need to look for,
how can I use this as a new page on my existing project ?
These videos are really good, I wish your course was cheaper.
Thanks for the kind words. If you live in a country where the currency doesn't convert well or have financial issues, feel free to reach out. I'm happy to give discounts to those in need.
@@seanallen Thanks you so much for your kind act and support, the course is a bit expensive when I convert it to my currency. To be honest, I believe there are people who need it more than me but I still wanna thank you for this act.
🙏Thank you
what about selecting a range and having it highlighted as you do it. why isn't this a feature. it is in android isn't it. so lacking the features for some things in swiftui
How does DatePicker show time in 24-hr format in the compact datepickerstyle. I need this for a military time application irrespective of users locale selection. No AM/PM.
For eg Time-22:54
In SwiftUI the DatePicker uses the system locale setting, so if the user has their phone set to 24-hr then that's what they'll get with the DatePicker. If you really want to set the locale explicitly you'd need to drop down to using UIDatePicker, which has a locale property, in a UIViewRepresentable.
@@jakubcharvat4902 Thanks for the reply buddy, I just found .environment modifier to the DatePicker which can set the Locale. I used “en_GB” to switch the DatePicker to 24-hr clock irrespective of the user’s preference.
@@netfreak9 Amazing, didn't think of using the environment, great find :)
Hi Sean I love your content I hope you reply to my query . Recently I booked a movie ticket on my iPhone on a website . After I booked , it showed up in my iPhone calendar. I want to implement this on an app I am building. Any ideas what to learn . I have previously seen this while I was setting up a .ics file. Still clueless, really hoping for your reply. Regards
I've never had to implement that feature before, so I don't know without researching it.
Hi Sean, just bump into your couple videos. I'm interested in taking your course, but before that I have couple questions. How can I reach you?
Hi Fariz, you can find my email in the "about" section on my youtube channel.
What's up with the yellow background and SwiftUI? :) I think a lot of people have faced that issue. Am I right?
I have no idea what you are referring to.
@@seanallen Oh, it wasn't pointed at you, Sean. I am sorry if it came across like that. It was just a comment for the community where SwiftUI views sometimes show up with the yellow background randomly. I was just trying to see how many people actually faced that issue.