flâneur — a map of the web's best reading

Building a menu using List - a free SwiftUI by Example tutorial

hackingwithswift.com · 1,734 words · saved by 1 readers

We’re going to start simple, and work our way up. Along the way you’ll start to see some of the things that SwiftUI makes easy, and some of the things that are a bit harder. In ContentView.swift is a basic struct representing the only screen in our app: ContentView. It looks like this: That isn’t much code, but it already tells us a lot: You should also see a preview pane on the right of Xcode. This updates as you type, which makes it a great way to see your changes as you work. If you don’t see the preview pane on the right, go to the Editor menu and choose Canvas. In the event that Xcode’s preview area stops – which will happen quite often – you can press Opt-Cmd-P to make it resume showing your layouts. This is really important so I’m repeating it: pressing Opt-Cmd-P will make your SwiftUI preview update. In our app this screen will show us a list of items from a menu, so we’re going to use a List view instead of Xcode’s default template code. So, replace the current text view with

Building a menu using List - a free SwiftUI by Example tutorial WWDC26: Save 50% on my books and bundles! >> < SwiftUI tutorial: Building a complete project Composing views to create a list row > Building a menu using List Paul Hudson @twostraws June 16th 2023 Updated for Xcode 16.4 We’re going to start simple, and work our way up. Along the way you’ll start to see some of the things that SwiftUI makes easy, and some of the things that are a bit harder. In ContentView.swift is a basic struct representing the only screen in our app: ContentView . It looks like this: struct ContentView: View { v

Explore this link on the map →

saved by

related reading