How to implement SwiftUI ViewModifier for Text content only?

I would like to implement following Modifier.

struct MyModifier: ViewModifier {
  typealias Body = SwiftUI.Text
  func body(content: Content) -> SwiftUI.Text {
    content.fontWeight(.heavy)
  }
}

But... I can't do this, because Content is a _ViewModifier_Content (View) and even cast to Text always fails.

1 Like