SwiftUI. How to wrap content in View

Artem Mykhelson
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.

👉 Buy Me a Coffee

Thanks for your support! 💛

--

--

Artem Mykhelson
Artem Mykhelson

Written by Artem Mykhelson

🚀 Code | 🎮 Game | 🎨 Create | 📝 Tech Reviews 💻 Sharing the process – Join the journey! 🔥

No responses yet