So I think I could be using ViewModifiers incorrectly, but is it possible to cast the Content of a ViewModifier to the anticipated type, e.g. Text? I want to use .fontWeight(.bold) but that is not part of the base/aliastype Content. Alternatively what should I use to achieve this effect? A custom Style function?
struct ButtonTextModifier: ViewModifier {
func body(content: Content) -> some View {
(content as Text) //<--- ERROR HERE
.fontWeight(.bold) //<--- Because I want to use this
.font(.largeTitle)
.padding()
}
}
The error I get:
Cannot convert value of type 'ButtonTextModifier.Content' (aka '_ViewModifier_Content<ButtonTextModifier>') to type 'Text' in coercion