I have a simple SwiftUI view like this, where the animation is performed correctly:
struct DemoView: View {
@State private var isAnimating = false
var body: some View {
Text("Hello")
.rotationEffect(.degrees(isAnimating ? 360 : 0))
.animation(.smooth.repeatForever(), value: isAnimating)
.onAppear(perform: {
isAnimating = true
})
}
}
But as soon as I wrapped its content or embedded it into a TabView the animation stop working (not performed):
struct DemoView: View {
@State private var isAnimating = false
var body: some View {
TabView {
Text("Hello")
.rotationEffect(.degrees(isAnimating ? 360 : 0))
.animation(.smooth.repeatForever(), value: isAnimating)
.onAppear(perform: {
isAnimating = true
})
}
}
}
Note: I’m testing this on a WatchOS project.