UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Small, Medium & large home screen widgets

Forums > SwiftUI

Hello, Just look to confirm something. I have developed a Large home screen widget. I've used different versions of that code to create a Medium and Small versions. I'm not sure how how I can implement the small and medium widgets. Do I need to use WidgetBundle to do this? Thank you!

2      

I am assuming that you are already using WidgetKit (as you have written a widget). You will also need to use .widgetFamily.

@Environment(\.widgetFamily) var family

and switch on the family to select the appropriate widget to display.

Have a look at the UlitmatePortfolio videos 42 and 43, which should give you some additional pointers.

Bear in mind that currently (19-May-2023) those videos are for the previous app created for the UltimatePortfolio, and not the current 2023 app (whose videos will appear in due course). Also, things might be a bit more swifty, rather than UI, now in Xcode 14.x.

3      

Great, thanks. I'll look into this. Thanks for the clarification.

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.