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...
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:
- Custom title and message.
- Text field with a placeholder and keyboard type.
- Confirm button, whose callback returns the content of the text field.
Reading time: 1 min
Ocassionally you wish to make a View fit entire width of its parent. You can do so by setting both
Text("Some text") .frame(minWidth: 0, maxWidth: .infinity)
Text specifically, this is even more useful if you wish to have it, say, leading-aligned in a center-...