LoginSignup
0
0

【SwiftUI】@ViewBuilder って逆にないほうが分かりやすくね ?

Posted at
struct TitleTextFormatView<Content: View>: View {
  var content: Content

  var body: some View {
    content
      .font(.title)
      .foregroundColor(.red)
  }
}

// Error:
// Type '() -> VStack<TupleView<(Text, Text)>>' cannot conform to 'View'

TitleTextFormatView {
  VStack {
    Text("top")
    Text("bottom")
  }
}

【SwiftUI】 今日のなんでやねん - @ViewBuilder
👉 https://android.benigumo.com/20240222/viewbuilder/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0