xcode 如何将“滑动”动画更改为其他动画?

ztyzrc3y  于 2023-05-23  发布在  其他
关注(0)|答案(1)|浏览(106)

每当我使用NavigationLink打开其他视图时,都会有一个默认的滑动动画,这很奇怪。我怎么把它改成别的东西?

NavigationLink(
                destination: recipeView().navigationBarBackButtonHidden(),
                isActive: $isActive1) {
                Button {
                    isActive1 = true
                    selectedTab = .recipe
                } label: {
                    VStack(alignment: .center, spacing: 4) {
                        if selectedTab == .recipe {
                            Rectangle()
                                .foregroundColor(selectedTab == .recipe ? Color("Orange") : Color.clear)
                                .frame(width: 90, height: 10)
                                .clipShape(BottomCornerRadius(radius: 5))
                                .offset(y: -11)
                        }
                        VStack {
                            Image(systemName: "fork.knife")
                                .font(.system(size: 30))
                                .foregroundColor(selectedTab == .recipe ? Color("Orange") : Color("tabColor"))
                            Text("Recipe")
                                .font(.system(size: 17, weight: .bold, design: .rounded))
                                .foregroundColor(selectedTab == .recipe ? Color("Orange") : Color("tabColor"))
                        }
                        .background(
                            Rectangle()
                                .frame(width: 100, height: 88)
                                .cornerRadius(10)
                                .foregroundColor(selectedTab == .recipe ? Color("Orange").opacity(0.2) : Color.clear)
                                .offset(y: -7)
                        )
                    }
                }
                .frame(width: UIScreen.main.bounds.width/3)
                .offset(x: 10)
            }
                .animation(.spring())
jc3wubiy

jc3wubiy1#

iOS导航的默认行为是3种方式。
1:推;这是你所说的滑动动画。
2:模态表,这是一个底部的表,几乎是顶部
3:FullscreenCover,这是一个覆盖屏幕的底部薄片。
然后你有其他自定义解决方案,但还没有任何好的swiftUI解决方案。
https://www.hackingwithswift.com/quick-start/swiftui/how-to-create-a-custom-transition是一个半过渡。

相关问题