Hey there, I would like to create a card game (I'm following the Stanford University's tutorial) and I want to Scroll the view according to the position of the mouse, like if it's to the top so I would like that it automatically rolls up, so if it's to the down, scroll automatically to the down: This is my code:
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View{
HStack {
CardView()
CardView()
CardView()
CardView()
}
.padding()
.foregroundColor(Color(.systemRed))
}
}
struct CardView: View {
@State var isFaceUp = false
var body: some View {
ZStack {
let shape = RoundedRectangle(cornerRadius: 20)
if isFaceUp {
shape.fill().foregroundColor(.white)
shape.stroke(lineWidth: 3)
Text("😀").font(.system(size: 80))
} else {
shape.fill()
}
}
.onTapGesture(perform: {
isFaceUp = !isFaceUp
})
}
}
PlaygroundPage.current.setLiveView(ContentView())