Created
November 8, 2023 07:49
-
-
Save tgnivekucn/b43067562f10018425b5a25d5071bc6c to your computer and use it in GitHub Desktop.
SwiftUI use opaque type example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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