Reading time: 8 min

This recipe shows how to format content of a SwiftUI Text with HTML via NSAttributedString. The solution isn't fully complete as it doesn't support all the HTML tags, nor does it support hyperlinks (even though they're supported in attributed strings) - but it gets the job done most of the time...

Continue Reading...

Reading time: 2 min

This recipe shows how to add a TextField to a SwiftUI alert dialog. The end result looks like this:

The dialog supports:

  1. Custom title and message.
  2. Text field with a placeholder and keyboard type.
  3. Confirm button, whose callback returns the content of the text field.
  4. Optiona...

Continue Reading...

Reading time: 1 min

Ocassionally you wish to make a View fit entire width of its parent. You can do so by setting both minWidth and maxWidth:

Text("Some text")
  .frame(minWidth: 0, maxWidth: .infinity)

For a Text specifically, this is even more useful if you wish to have it, say, leading-aligned in a center-...

Continue Reading...