Just can't get my head around this. I have a simple animation which works perfectly. But when I wrap the view into a ScrollView (by uncommenting the 2 lines) it does not animate anymore? Anybody a clue?
import SwiftUI
struct ContentView: View {
@State var offset = CGSize(width: 0, height: 0)
var body: some View {
// ScrollView {
VStack(spacing: 50) {
Rectangle()
.frame(width: 100, height: 100)
.offset(self.offset)
Button(action: {
withAnimation {
self.offset.width += 66
}
})
{
Text("Animate me")
}
}.frame(width: 300)
// }
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}