I keep getting this message in the Xcode console when "Tap Me" is hit.
Is this a bug? Am I doing something wrong? Any thoughts?
ignoring singular matrix: ProjectionTransform(m11: 5e-324, m12: 0.0, m13: 0.0, m21: 0.0, m22: 5e-324, m23: 0.0, m31: 10.5, m32: 0.0, m33: 1.0)
This is the code that illustrates the problem, certainly related to the animation. Xcode version: 13.3, on Monterey: 12.3.1
struct ContentView: View {
@State private var letter = "A"
@State var isAnimating: Bool = false
var body: some View {
VStack {
Button("Tap Me") {
if letter == "A" {
letter = "B"
} else {
letter = "A"
}
}.font(.largeTitle)
Text(letter).font(.largeTitle).scaleEffect( isAnimating ? 1.0 : 0, anchor: .top)
.onAppear {
isAnimating = true
}
.onChange(of: letter) { _ in
isAnimating = false
withAnimation {
isAnimating = true
}
}
}
}
}
As the dog mentions, changing the 0 in:
scaleEffect( isAnimating ? 1.0 : 0 )
to
scaleEffect( isAnimating ? 1.0 : 0.001 )
gets rid of the error. Still, you'd think this would be better handled by the library.