我想像 safari 一样按滚动方向显示或隐藏项目。向上滚动时隐藏某些内容,向下滚动时显示它。
我在我的代码中使用了以下示例(iOS SwiftUI:以编程方式弹出或关闭视图),但我不知道如何创建动画,就像翻页一样,并在点击 [Button] 时延迟几秒钟。有谁知道解决方案?
struct DetailView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var body: some View {
Button(
"Here is Detail View. Tap to go back.",
action: {
//withAnimation(.linear(duration: 5).delay(5))// Error occurred in dalay.(Type of expression is ambiguous without more context)
withAnimation(.linear(duration: 5)) // not work
{
self.presentationMode.wrappedValue.dismiss()
}
}
)
}
}
struct RootView: View {
var body: some View {
VStack {
NavigationLink(destination: DetailView())
{ Text("I am Root. Tap for Detail View.")
}
}
}
struct …Run Code Online (Sandbox Code Playgroud)