SwiftUI. How to wrap content in View
Mar 29, 2022
Hi! Another short how-to on SwiftUI.
If you ever faced the question: “How to make SwiftUI view wrap its content?”. The answer is simple:
Text("Hello World!")
.padding(16)
.frame(
minWidth: 0,
maxWidth: .infinity,
minHeight: 0,
maxHeight: .infinity,
alignment: .topLeading
)
Such a modifier for Text view will make it wrap its content inside your view, no matter where you place it.
That’s it. Happy coding!
☕ Enjoying this content? Support me!
Creating quality content takes time and effort, and your support helps keep it going! If you found this article helpful, consider buying me a coffee — it’s a small gesture that makes a big difference.
Thanks for your support! 💛