Section
Form
中的过渡总是左右,有些情况下我想改成左右,我试过.transition
与 .move
修饰符,但没有效果。
struct ContentView: View {
@State var visible = true
var body: some View {
Form {
Button("visible") {
self.visible.toggle()
}
visible ? Section {
Text("Section 1")
Text("Section 1")
}.transition(.move(edge: .leading)) : nil
!visible ? Section {
Text("Section 2")
Text("Section 2")
}.transition(.move(edge: .trailing)) : nil
Section {
Text("Section 3")
Text("Section 3")
} // Section 3 should not be animated
}.animation(.linear(duration: 0.5))
}
}
最佳答案
我阅读了大量 Apple 的 SwiftUI 表单代码文档,似乎很少有自定义选项;特别是您当前设置代码的方式。在这方面,我建议从头开始创建动画和页面。这样做,您将拥有过渡方向的完全创作自由。这需要做很多工作才能看起来像一个表单,但这是可能的。以下答案将为您提供左右转换:https://stackoverflow.com/a/62144939/13296047
关于ios - SwiftUI 表单中的部分转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63067976/