Reading time: 1 min

This recipe shows how to style SwiftUI TextField's prompt / placeholder text, in order to, e.g, change its color or font. Alternatively, you can put a fully custom view for the placeholder. The end result looks like this:

preview

Since there is no built-in way of doing this, we'll have to resort...

Continue Reading...

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

This recipe shows how to implement an async binding in SwiftUI. Just like a regular Binding, async binding creates a two-way connection between a property that stores data, and a view that displays and changes the data - except that those changes are expressed with async blocks.

This allows...

Continue Reading...

Reading time: 1 min

This recipe shows how to perform delayed actions in SwiftUI. It also shows examples of how to implement a delayed onAppear for async and non-async blocks. The end result looks like this:

preview

There are two ways to delay actions in Swift in general:

  • Using DispatchQueue with asyncAfter with a...

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...