首页 > 解决方案 > NavigationView / NavigationLink 自定义过渡方向

问题描述

我试图NavigationLink从屏幕底部加载视图,而不是从右侧过渡,但“明显”的方法(使用 a .transition(.move(edge: .bottom)))似乎没有任何效果。

下面是里面的NavigationView

List {
    ForEach(self.message, id: \.self) { message in
        HStack(alignment: .center) {
            MessageListCell(....)
        }
    }
}

MessageListCell

    var body: some View {
        HStack {
            VStack(alignment: .leading, spacing: 0) {
                Text(person.firstName).lineLimit(1)
                    .foregroundColor(.main)
            }
            Spacer()
            NavigationLink(destination: MessageDetail(otherPerson: otherPerson,
                                                   subject: subject,
                                                   profileHandler: { ProfileReducer($0) })
                .transition(.move(edge: .bottom)),
                           tag: 1, selection: $action) {
                NextButton("Proceed")
            }
        }
    }

NextButton从屏幕右侧而不是底部点击一致的过渡。我已经尝试过上述方法的变化,但我开始认为这transition可能不是正确的方法。

标签: swiftuiswiftui-navigationlink

解决方案


推荐阅读