I am trying to pass font weight as a parameter to a component (SwiftUI View) to then use with Text. How can I do this?
I tried to set weight as Weight, UIFontDescriptor.TraitKey (found by searching), but neither work.
E.g.
let weight: Weight = .bold
init(weight: Weight){
self.weight = weight
}
>Solution :
There’s a pretty quick way to figure out the type.
In a SwiftUI view write something like
Text("Hello").fontWeight(.bold)
Then ⌥-click on .bold and you’ll see
