Created
September 26, 2023 11:42
-
-
Save no13bus/338f101fc41c4f1675356c58384a3dbc to your computer and use it in GitHub Desktop.
tabbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Example-iOS | |
// | |
// Created by Alex.M on 26.05.2022. | |
// | |
import SwiftUI | |
class Visible: ObservableObject { | |
@Published var visible: Visibility = .visible | |
} | |
struct New: View { | |
@EnvironmentObject var visible: Visible | |
var body: some View { | |
Text("Hello, World!") | |
.onAppear { | |
withAnimation(.spring()) { | |
visible.visible = .hidden | |
} | |
} | |
.onDisappear { | |
withAnimation(.spring()) { | |
visible.visible = .visible | |
} | |
} | |
} | |
} | |
struct ContentView: View { | |
@StateObject var visible: Visible = Visible() | |
var body: some View { | |
TabView { | |
NavigationView { | |
VStack{ | |
NavigationLink { | |
New() | |
} label: { | |
Text("Home") | |
} | |
} | |
}.toolbar(visible.visible, for: .tabBar) | |
.tabItem { | |
Label("Home", systemImage: "gear") | |
} | |
}.environmentObject(visible) | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment