在没有导航视图的视图之间切换

问题描述

我正在尝试做到这一点,因此,当我单击用户名按钮时,会弹出一个新视图,全屏显示我为用户名视图创建的视图。我已经尝试过navigationView,但是我不喜欢标题显示在主视图中。我试过使用可以正常工作的工作表,但它不能覆盖整个屏幕。有什么办法可以在我喜欢的MainScreen.swift,Username.swift和Data.swift之类的不同视图之间切换 谢谢!

//Creating booleans to show sheets of different menus
@State var showUser: Bool = false
@State var showData: Bool = false


var body: some View {
    //Making
    ScrollView(.vertical){
        VStack{
            //User button
           
                Button(action: {
                    withAnimation{
                        self.showUser = true
                    }
                })
                {
                    // Creating Hstack for name of button and image
                    HStack{
                        //Text of button
                        Text("Username")
                            .font(.custom("Futura",size: 17))
                            .fontWeight(.ultraLight)
                        //Image of button
                        Image(systemName: "person.crop.circle.fill")
                        
                    } //Hstack
                        .aspectRatio(contentMode: .fit)
                        .frame(minWidth: 0,maxWidth: 300)
                        .padding()
                        .background(RoundedRectangle(cornerRadius: 10).stroke(Color.blue,lineWidth: 2))
                        .padding(.top,5)
                        .padding(.bottom,5)
                    
                    //username button settings
                } //user button
        
        
        
                //Data button
                if showData {
                    Data()
                        .animation(.spring())
                        .transition(.slide)
                }  else {
                Button(action:{
                    withAnimation{
                    self.showData = true
                    }
                    
                })
                {
                    // Creating Hstack for data and image
                    HStack{
                        // Text of button
                        Text("Data")
                            .font(.custom("Futura",size: 17))
                            .fontWeight(.ultraLight)
                        // Image of button
                        Image(systemName: "chart.pie")
                        
                    } //Hstack
                        .padding(.top,180.0)
                        .padding(.bottom,2)
                        .aspectRatio(contentMode: .fit)
                        .frame(minWidth: 0,maxWidth: 300)
                        .frame(minHeight: 0,maxHeight: 200)
                        .padding()
                        .background(RoundedRectangle(cornerRadius: 10).stroke(Color.blue,lineWidth: 2))
                        .padding(.bottom,50)
                    //Data button settings
                } //data button
            }//showing data sheet
        

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...