Swiftui 旋转3D效果对文本具有不希望的效果

Swiftui 旋转3D效果对文本具有不希望的效果,swiftui,Swiftui,这个问题与其他动画问题有何不同:我没有看到任何涉及反向文本的文章。请参阅下文: 以下是导致这种情况的代码: .rotation3DEffect( .init(degrees: isTapped ? 180 : 0), axis: (x: 0.0, y: 1.0, z: 0.0), anchor: .center, anchorZ: 20.0, perspective: 1.

这个问题与其他动画问题有何不同:我没有看到任何涉及反向文本的文章。请参阅下文:

以下是导致这种情况的代码:

 .rotation3DEffect(
            .init(degrees: isTapped ? 180 : 0),
            axis: (x: 0.0, y: 1.0, z: 0.0),
            anchor: .center,
            anchorZ: 20.0,
            perspective: 1.0
        )
以下是我试图解决的问题:

  • 尝试将180º替换为360º,这当然会使卡片旋转两次(不需要,但会使文本笔直)
  • 尝试使用.reversed()作为解决方法
  • 使用3DEffect的所有参数都无效
  • 在互联网上搜索解决方案,没有找到这个特定问题的答案
  • 编辑如果有人知道返回阿拉伯文视图时文本为什么会呈现这样的效果,也可以编辑。。这将是巨大的额外援助

    编辑添加示例代码,只需复制粘贴即可

    编辑另一次编辑,忘了我曾尝试使用.reversed()作为解决方法

    import SwiftUI
    
    struct ContentView: View {
        let grid = [GridItem(.fixed(100), spacing: 5, alignment: .center),
                    GridItem(.fixed(100), spacing: 5, alignment: .center),
                    GridItem(.fixed(100), spacing: 5, alignment: .center)]
        var body: some View {
            VStack {
                LazyVGrid(columns: grid, content: {
                    ForEach(Example.example, id: \.name) { ex in
                        AnimatedView(data: ex)
                    }
                })
            }
        }
    }
    
    struct ContentView_Previews: PreviewProvider {
        static var previews: some View {
            ContentView()
        }
    }
    
    
    struct Example {
        let name: String
        let translation: String
        
        static let example =
            [Example(name: "First", translation: "Second"),
             Example(name: "Third", translation: "Fourth"),
             Example(name: "Fifth", translation: "Sixth"),
             Example(name: "Seventh", translation: "Eigth"),
             Example(name: "Ninth", translation: "Tenth"),
             Example(name: "Eleventh", translation: "Twelth")
            ]
    }
    
    struct AnimatedView: View {
        @State private var isTapped = false
        
        let data: Example
        
        var body: some View {
            Button(action: {self.isTapped.toggle()}) {
                Text(isTapped ? data.name : data.translation)
                    .padding()
                    .foregroundColor(.white)
                    .frame(width: 100)
                    .background(isTapped ? Color.blue : .black)
                    .cornerRadius(8)
            }.rotation3DEffect(
                .init(degrees: isTapped ? 180 : 0),
                axis: (x: 0.0, y: 1.0, z: 0.0),
                anchor: .center,
                anchorZ: 0,
                perspective: 0
            )
            .animation(.linear)
        }
    }
    
    struct AnimatedView:View{
    @状态私有变量isTapped=false
    let数据:示例
    var body:一些观点{
    按钮(操作:{self.istaped.toggle()}){
    文本(isTapped?data.name:data.translation)
    .padding()
    .foregroundColor(.白色)
    .框架(宽度:100)
    .background(isTapped?Color.blue:.黑色)
    .转弯半径(8)
    
    .rotation3DEffect(//你会添加一些可复制的代码吗?@Yodagama是的,抱歉,我刚刚添加了。可以将其直接插入XcodeWorth,考虑通过单独的组件制作,如中。我们可以使用动画数据来获得更好的旋转效果,如真卡!如果可能,希望看到一个简短的示例或一个好的参考