Reading time: 1 min

This recipe shows how to update navigation bar when the content underneath it scrolls. The end result looks like this:

preview

The recipe relies on the ObservableScrollView from this recipe, because it can track its scroll offset. After that, it becomes trivial to check if the user has scrolled p...

Continue Reading...

Reading time: 1 min

This quick recipe shows how to put any custom view in a navigation bar, replacing the default navigation bar title text. Of course, that view can be interactable and respond to user input. The end result looks like this:

preview

This solution works for SwiftUI 2+ (iOS 14+, macOS 11+).

The tric...

Continue Reading...

Reading time: 2 min

This tutorial shows how to style a navigation bar in SwiftUI - changing its background color, text color, as well as styling the status bar. The end result looks like this:

This component is available as a Swift Package in this repo.

The gist of the work is in using a ViewModifier...

Continue Reading...

Reading time: 5 min

This recipe is a cheatsheet for various ToolbarItemPlacement values and combinations on iOS. This is useful because:

  1. The namings of the placement values don't necessarily clearly depict where will a ToolbarItem end up.
  2. Some values don't play well with each other. E.g, .primaryAction will...

Continue Reading...

Reading time: 1 min

This tutorial shows how to customize the navigation bar buttons as images. It applies to both the back button, as well as the button on the right-hand side. The end result will look something like this:

Customized navigation bar buttons

To do so, use the navigationBarItems(leading:trailing) method. As always, the navigation...

Continue Reading...