animation - NavigationView 导致动画错误?
问题描述
我偶然发现了一个看起来像由NavigationView
.
对于此处的可重现代码,我们有两个脉动的圆圈。它工作正常,直到我们添加NavigationView
!到底是怎么回事?我很确定这是一个错误,但是众所周知,有什么解决方法吗?
毛刺动画一瞥
可重现的代码:
import SwiftUI
struct ContentView: View {
@State private var animationAmount: CGFloat = 1
var body: some View {
NavigationView {
HStack {
Circle()
.frame(width: 100, height: 100)
.overlay (
Circle()
.stroke()
.scaleEffect(animationAmount)
.opacity(Double(2 - animationAmount))
.animation(
Animation.easeInOut(duration: 1).repeatForever(autoreverses: false)
)
).onAppear {
self.animationAmount = 2
}
Circle()
.frame(width: 100, height: 100)
.overlay (
Circle()
.stroke()
.scaleEffect(animationAmount)
.opacity(Double(2 - animationAmount))
.animation(
Animation.easeInOut(duration: 1).repeatForever(autoreverses: false)
))
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}