TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

How make View above Tabbar?

Forums > SwiftUI

@mrgg  

Hi,

I try to make custom Action Sheet, but when I have TabBar on the view, this TabBar is always visible (Action Sheet is under this TabBar).

How I can make this Action Sheet above Tabbar? Many apps have that custom Action sheet (like Instagram or Spotify).

I try zindex(999999) on Action sheet but didn't work...

ps. may I have to do custom TabBar?

2      

Not sure how you calling "Action Sheet".

However if you do

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

    var body: some View {
        TabView {
            Button("Tab One") {
                showSheet.toggle()
            }
            .tabItem {
                Label("One", systemImage: "1.circle")
            }
            Text("Tab Two")
                .tabItem {
                    Label("Two", systemImage: "2.circle")
                }
            Text("Tab Three")
                .tabItem {
                    Label("Three", systemImage: "3.circle")
                }
        }
        .sheet(isPresented: $showSheet) {
            MyCustomSheet()
        }
    }
}

This will present the sheet over the Tab Bar

2      

@mrgg  

Custom Action Sheet is some like this:

its normal View with offset so if i try do this, i get the:

right side - tab bar always visible

2      

Would be better if you could provide some code, so that others could help you solve this task. There may be many reasons why this is not happening the way you want but without peeking into your code it's just pointing a finger at the sky.

2      

I agreed with @ygeras as the code sippet that I gave before would work for the top image as you can customise the sheet view to what ever you need. See this video What's New In Xcode 14.3: You Won't Believe What's Changed!

However think you trying to use .actionSheet (which will be Deprecated and should be using confirmationDialog instead).

This will also cover the "TabBar"

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

    var body: some View {
        TabView {
            Button("Tab One") {
                showSheet.toggle()
            }
            .tabItem {
                Label("One", systemImage: "1.circle")
            }
            Text("Tab Two")
                .tabItem {
                    Label("Two", systemImage: "2.circle")
                }
            Text("Tab Three")
                .tabItem {
                    Label("Three", systemImage: "3.circle")
                }
        }
        .confirmationDialog("Title", isPresented: $showSheet, titleVisibility: .visible) {
            Button("One") { }
            Button("Two") { }
            Button("Three") { }
            Button("Four") { }
        }
    }
}

2      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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.