Some issue here.
I have a MVP that outlines to issue easily:
import SwiftUI
struct ContentView: View {
var body: some View {
List {
Element()
Element()
Element()
}
}
}
struct Element: View {
@State var isOn: Bool = false
var body: some View {
VStack {
HStack {
Text("Hello, World!")
Button("Toggle") {
isOn.toggle()
}
}
if isOn {
Text("It's on!")
.transition(.opacity)
}
}
.animation(.default, value: isOn)
}
}
#Preview {
ContentView()
.frame(width: 400)
}
When using LazyVStack instead of List, the animation works flawlessly.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: