Reading time: 2 min

This recipe shows how to detect backspace event in SwiftUI TextField. The method can figure out both if it's a forward or in-text backspace, and doesn't rely on hacks on hidden characters.

Continue Reading...

Reading time: 1 min

This quick recipe shows how to limit the length of a SwiftUI TextField input.

Continue Reading...

Reading time: 1 min

This recipe shows how to implement a multiline text field in SwiftUI that expands automatically.

Continue Reading...

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.

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, SecureField doesn't have such a parameter, and there's no way to know if the user is interacting with the view!

Continue Reading...