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

Composing views to create a list row - a free SwiftUI by Example tutorial

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

Just having names of menu items written out isn’t particularly appealing for a restaurant, so let’s make those items look good. First, though, an important lesson: SwiftUI is designed to be composable, which means you can make views out of any other views you like. We have a simple text view for our items right now, Text(item.name), but we’re going to add much more in there to bring it to life. While we could put that directly into ContentView.swift, it becomes long and hard to read. A better idea is to make a new view type that we can embed inside ContentView, and SwiftUI is designed to make this both easy (it takes only 30 seconds to learn) and extremely fast (it has almost zero performance impact). So, press Cmd+N to create a new file, choose SwiftUI View under the User Interface category, then call it “ItemRow”. You’ll see Xcode has generated a new view with some sample code to get us started: We’re going to be doing something new in just a moment, but first I want to get us to the

Composing views to create a list row - a free SwiftUI by Example tutorial WWDC26: Save 50% on my books and bundles! >> < Building a menu using List Polishing designs with fonts and colors > Composing views to create a list row Paul Hudson @twostraws April 30th 2024 Updated for Xcode 16.4 Just having names of menu items written out isn’t particularly appealing for a restaurant, so let’s make those items look good. First, though, an important lesson: SwiftUI is designed to be composable , which means you can make views out of any other views you like. We have a simple text view for our items rig

Explore this link on the map →

related reading