Reading time: 1 min

This recipe shows how to navigate from one text field to another using keyboard buttons in SwiftUI by combining @FocusState and onSubmit. The end result looks like this:

preview

The recipe goes as following:

  1. Declare an enum that holds aliases for focusable fields. In the code below, that's Form...

Continue Reading...

Reading time: 2 min

Detecting if a text field gained or lost focus is not entirely straightforward in SwiftUI.

TextField constructor has a parameter named onEditingChanged, but it triggers only when the user taps the return key in the virtual keyboard, not when the focus is actually lost.

Even worse, SecureFi...

Continue Reading...