struct ContentView: View {
var body: some View {
ZStack {
Color.red
Color.blue
.frame(width: 50, height: 50)
.padding(10)
Color.blue
.frame(width: 50, height: 50)
.position(x: 50/2, y: 50/2)
.padding(10)
}
.aspectRatio(1, contentMode: .fit)
.padding(10)
}
} import SwiftUI
@main
struct FooApp: App {
@State private var isClicked: Bool = false
var body: some Scene {
WindowGroup {
VStack {
Button("Click me!") { isClicked.toggle() }
if isClicked { Text("Hello, World!") }
}.frame(width: 640, height: 480)
}
}
}
https://www.youtube.com/watch?v=hmiJ0OzFKd0