本文介绍了无法使用 NavigationLink?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    NavigationView {
          ScrollView{
                 .navigationTitle("Home")
                 .toolbar {
                     ToolbarItemGroup(placement: .bottomBar) {
                                VStack{
                                    HStack{
                                        NavigationLink(
                                            destination: Home(),
                                            label: {
                                                Image(systemName: "house")
                                                    .resizable()
                                                    .frame(width: 25.0, height: 20.0)
                                                    .foregroundColor(.blue)
                                                    .padding()
                                            })
       }
    }
                                  

我无法使用 NavigationLink(destination : Text("Go home page"),label:{}

I cant use NavigationLink(destination : Text("Go home page"),label:{}

这是菜单栏我想在向下或向上滚动时冻结此菜单栏

It is menu bar I want to freeze this menu bar when I scroll down or up

非常感谢

推荐答案

import SwiftUI
struct HomeNav: View {
    @State var isActiveHome: Bool = false
    var body: some View {
        NavigationView {
            ScrollView{
                Text("Main")
                NavigationLink(
                    destination: Text("Home").navigationTitle("Home"),
                    isActive: $isActiveHome,
                    label: {
                        Image(systemName: "house")
                            .resizable()
                            .frame(width: 25.0, height: 20.0)
                            .foregroundColor(.blue)
                            .padding()
                    }).hidden().frame(width: 0, height: 0, alignment: .center)
                    .navigationTitle("Main")
                    .toolbar {
                        ToolbarItemGroup(placement: .bottomBar) {
                            VStack{
                                HStack{
                                    Button(action: {
                                        isActiveHome = true
                                    }, label: {
                                        Image(systemName: "house")
                                            .resizable()
                                            .frame(width: 25.0, height: 20.0)
                                            .foregroundColor(.blue)
                                            .padding()
                                    })
                                }
                            }
                            
                        }
                    }
            }
        }
    }
}

这篇关于无法使用 NavigationLink?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 03:23