-
Segmented Control in SwiftUI
Another option we can use for horizontal navigation is the segmented control. In this post, we’ll learn: Create the segment control Let’s start by creating a segment control that allows choosing from the days of the week: So, the Segment Control is created by using a Picker and setting its style to segmented. If you…
-
Sheet
An important element in iOS is the Sheet. In this post, we will cover: In this example i use this image Unsplash Creating a Non-Full-Screen Sheet Begin by creating the project and adding the image to the assets. I’ve renamed the image to background. First, we add a ‘plus’ button to the toolbar. When this…
-
Navigation Title and Toolbar
We can configure the navigation bar by adding the title and defining how to display it. To achieve this: It is also possible to set the title at the top and center it by adding the display mode like this: The default display mode is automatic, which means the title is displayed large and aligned…
-
NavigationStack & TabView
Often, or perhaps always, we have a hierarchical navigation (NavigationStack) combined with horizontal navigation (TabView). Let’s see how to merge them: We have declared a NavigationStack that contains the TabView. Now, within any of the tabs, we can navigate forward and return. Here is the FirstView: Instead, here is the ThirdView: To achieve this: If,…
-
TabView
One of the changes I like in SwiftUI, released with Xcode 16, is the new way to write a TabView. Now we can write: To have: We can define a View to use in the first tab, for example. Feel free to customize the others as you like. Now in the Tab: We can also…
-
Navigation
The iOS application uses two main components to allow navigation: NavigationStack and TabView. In this post, we’ll focus on the first one. For simplicity, we’ll start by implementing navigation, moving from one view to an empty view. The main component is the NavigationStack. You should define only one NavigationStack in the root view of your…