Reading time: 1 min

This recipe shows how to disable scrolling in a ScrollView or List, while still allowing interactions with its subviews. The end result looks like this:

preview

The trick is to use a DragGesture with minimumDistance of zero, which will then intercept scrolling touches, while still allowing taps an...

Continue Reading...

Reading time: 1 min

This quick recipe shows how to enable multiple Buttons in a List row. This is a long standing SwiftUI bug/quirk that fortunately has an easy workaround. Say you've put a few buttons in a List row:

preview

using code like this:

List {
  HStack {
    Button("First button") {
      print("First actio...

Continue Reading...

Reading time: 1 min

This recipe shows how to add a sticky header to a List in SwiftUI. It also allows for a scrolling part of the header, as well as multiple sticky headers. The end result looks like this:

preview

The recipe goes as follows:

  • Use Section(header:) to define the sticky header and the content beneath...

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

This recipe shows how to implement a timeline list in SwiftUI. Timeline list has a line, usually on the side, that connects rows / cells tied to the same date. The end result looks like this:

Screenshot%202021-11-18%20at%2013.38.17

The example list in this recipe deals with a simple structure that represents an appointment, defi...

Continue Reading...