I'm having an app with a tab bar navigation concept. For one view I'm currently trying to implement a tab bar overlay that you all know from the Photos App in iOS. It appears when you select images. See below:
I tried to implement this behavior in the below code snippet but I have two doubts:
- is
.overlay()
the right way to do it? I wanted to combine it with a State and set it accordingly to enable / disable the overlay. - if overlay is ok from a coding point of view, how would I align it to the bottom and take care of the sizing so that it exactly overlays the tab bar?
struct ContentView: View {
var body: some View {
TabView {
NavigationView {
Text("First Nav Page")
}
.tabItem {
Image(systemName: "house")
Text("Home")
}.tag(0)
NavigationView {
Text("Second Nav Page")
}
.tabItem {
Image(systemName: "gear")
Text("Settings")
}.tag(1)
Text("No Nav Page")
.tabItem{
Image(systemName: "plus")
Text("Test")
}.tag(2)
}.overlay(
Rectangle()
.foregroundColor(.red)
.frame(width: 40, height: 40)
)
}
}
Thanks!