Skip to content

Instantly share code, notes, and snippets.

@tgnivekucn
Created November 8, 2023 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgnivekucn/b43067562f10018425b5a25d5071bc6c to your computer and use it in GitHub Desktop.
Save tgnivekucn/b43067562f10018425b5a25d5071bc6c to your computer and use it in GitHub Desktop.
SwiftUI use opaque type example
// Note: The type of body is: ModifiedContent<VStack<TupleView<(Text, Button<Text>, Text)>>, _PaddingLayout>
struct ContentView: View {
var body: some View {
VStack {
Text("Hello, world! (1)")
Button("print my type") {
print(type(of: self.body))
}
Text("Hello, world! (2)")
}
.padding()
}
}
// Note: The type of body is: ModifiedContent<VStack<TupleView<(Image, Button<Text>, Image)>>, _PaddingLayout>
struct ContentView2: View {
var body: some View {
VStack {
Image(systemName: "globe")
Button("print my type") {
print(type(of: self.body))
}
Image(systemName: "globe")
}
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment