Understanding the swiftUI code hierarchy

Hi Team,

I just started swiftUI and would like to understand the properties, parameters, arguments of the swiftUI. For example consider the below example. Is .system part of the font function or is it separate function?

Text("by William Shakespeare")
    .font(.system(size: 12, weight: .light, design: .serif))
    .italic()
1 Like

SwiftUI isn't covered by this forum, but luckily your question isn't actually about SwiftUI, that's a Swift thing: .system(...) is an argument being passed to font(...), not part of it. Specifically, it's a shorthand notation for Font.system(size: 12, weight: Font.Weight.light, design: Font.Design.serif)).

3 Likes

Got it. But we're not importing the Font in our View. How can we use something that's not imported?

1 Like

Font is a type from SwiftUI. Likewise, Text and even View are types from SwiftUI. In Swift we generally do not import specific types, but a whole module.

2 Likes