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: 3 min

This recipe shows how to add section index with titles to a SwiftUI List. This will render a vertical list of custom shortcuts on the right-hand side of the list, allowing you to quickly navigate to any section by pressing or just moving your finger over it. The same functionality in UITableVie...

Continue Reading...

Reading time: 5 min

This recipe shows how to detect when touch enters or exits your view. It shows how to do this for for two scenarios:

  1. Detect enter/exit in a single view.
  2. Detect enter/exit on a group of views, all sharing a single gesture.

The end results look like this:

preview_singlepreview_group

Detecting Enter and Exit on
...

Continue Reading...

Reading time: 3 min

This recipe shows how to add weights to HStack and VStack elements, so that you can easily size them relative to each other. E.g, if you had two views, one with weight of 10, and the other with weight of 5, the first one would be twice as wide / tall as the second one. The end result looks lik...

Continue Reading...

Reading time: 1 min

This recipe shows how to use fullScreenCover on iOS 13 (or any SwiftUI version, for that matter). It provides a drop-in replacement, fullScreenCoverCompat modifier that does the same trick regardless of what OS version you're running. The end result looks like this:

preview

Here's the code:

stru...

Continue Reading...