UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: TabView with .Sheet action ?????

Forums > SwiftUI

Is it possible to have a TabView with a .sheet action? I have tried without a success. Instead of Calling a for a new View, What I realy need is when I click on a Tab that I am able to have a .Sheet action.

is this possible?

3      

Hi @hcri50

I do not think that the TabView will do that! However you could use the toolbar (.bottomBar) to do that. Did some dummy code as example

struct ContentView: View {
    @State private var showingSheet = false

    var body: some View {
        NavigationView {
        Text("Hello, world!")
            .toolbar {
                ToolbarItemGroup(placement: .bottomBar) {
                    Spacer()
                    Button {
                          //action
                    } label: {
                        Label("Main", systemImage: "house")
                    }
                    Spacer()
                    Button {
                        showingSheet = true
                    } label: {
                        Label("Main", systemImage: "square.and.arrow.up")
                    }
                    Spacer()
                }
            }
            .sheet(isPresented: $showingSheet) {
                Text("This is s sheet view")
            }
        }
    }
}

but it a hack

3      

YOU ARE INCREDIBLE, Nigel, can you please do me a BIG FAVOR. Could you please go to my website and click on my email. For I would like to send you something special as my appreciation.

Sincerely, Robert B. De Saeger

https://joshuashousehospice.org/contact/

3      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.