๐ฐPresentations
๐ SwiftUI Tutorials โฉ Working with UI Controls โฉ Display a User Profile - Step 8.
// Toolbar & Modal Sheet
struct CategoryHome: View {
@EnvironmentObject var modelData: ModelData
/// โญ๏ธ 1. control the presentation of the `ProfileHost` view
@State private var showingProfile = false
var body: some View {
NavigationView {
List { /* list items ... */ }
.navigationTitle("Featured")
/// โญ๏ธ 2. add a button to the navigation bar
.toolbar {
Button { showingProfile.toggle() } label: {
Label("User Profile", systemImage: "person.crop.circle")
}
}
/// โญ๏ธ 3. present the `ProfileHost` view when the user taps the button.
.sheet(isPresented: $showingProfile) {
ProfileHost().environmentObject(modelData)
}
}
}
}
SwiftUI Tutorials โฉ Working with UI Controls โฉ Display a User Profile - Step 8.
SwiftUI โฉ View โฉ
ToolbarItem (struct)
toolbar(content:) - where Content :
View
.toolbar(content:) - where Content : ToolbarContent
.toolbar(id:content:) - where Content :
CustomizableToolbarContent
View Presentation
Design+Code โฉ SwiftUI Handbook โฉ ToolBar
Swift with Majid โฉ Mastering toolbars in SwiftUI
Sarun โฉ How to dismiss sheet in SwiftUI
Last updated