Your Second iOS & SwiftUI App, Episode 2: List Rows | raywenderlich.com

A List is a View for organizing data into a scrollable column of rows, and a row can be any View! Before you can have a list, you need a reusable row.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/25836622-your-second-ios-swiftui-app/lessons/2

Hi, can you please explain why you used .font(Font.title.weight(.light)) for Image? I’m mainly interested in Font modifier. Thanks.

Hi! SF Symbols are sort of special. Because they are vector images that Apple provides, they’ve made it so that in addition to treating them like images, they all come with a full selection of sizes and weights so you can treat them similar to text. I recommend checking out the SF Symbols app to see what the options are for different symbols.

The way to set the weight in iOS 16 would be to use the .fontWeight modifier like so:

Image(systemName: "book")
  .fontWeight(.light)

If you wanted to style an SF Symbol to match some text, you can also add an SF Symbol directly to a string with string interpolation, and modify them together like so:

Text("Title for a \(Image(systemName: "book"))")
  .fontWeight(.black)
  .foregroundColor(.secondary)