当 .rotation3dEffect 在 Apple Watch listRow 中设置动画时,该行似乎在前一行上方进行动画处理(这是所需的),但动画似乎发生在下一行下方,这破坏了 3d 效果。这个动画怎么也发生在下一行之上?
import SwiftUI
struct TestView: View {
let colors: [Color] = [.red,.blue,.green,.pink,.purple,.black,.brown,.cyan,.indigo,.teal]
var body: some View {
List {
ForEach(0..<10) { i in
RowView(color: colors[i])
}
}
.listStyle(.carousel)
}
}
struct RowView: View {
let color: Color
@State private var rotationAngle: Double = 0
var body: some View {
Button(action: {
withAnimation(.easeInOut(duration: 3.0)) {
rotationAngle += 180
}
}) {
HStack {
Text("Test Row")
Spacer()
}
.frame(height: 100)
.background(color)
.rotation3DEffect(
Angle.degrees(rotationAngle),
axis: (0,1,0),
perspective: 1.0
)
}
}
}