-
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). We can merge them in two main ways. Let’s see how to merge them using the first approach (which I don’t recommend because we lose the TabView). First way We have declared a NavigationStack that contains the TabView. Now, within…
-
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…
-
List Search
SwiftUI includes a SearchBar component starting from iOS 15. Start with this code to display a list of vehicles: To implement the search we have to do: Note that the ForEach now iterates over the searchResult, which contains all the vehicles if the searchText is empty, or the search results based on the vehicle’s name…
-
List Actions
In the previous post, we saw how to create a List. In this one, we’ll learn how to perform actions on the list, primarily deletion. Before that, we need to introduce a new magic word: ForEach.Take a look at the code below: To have: As you can see, in this case, we only have a…