0

我正在努力做到这一点,所以当我单击用户名按钮时,会弹出一个全屏视图,其中包含我为用户名视图创建的内容。我试过 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
        
4

0 回答 0