Top 5 New SwiftUI Modifiers You Need To Know
New SwiftUI modifiers released in iOS 15 unlock the true declarative superpower of SwiftUI and help you build better apps!
At WWDC 2021, the SwiftUI team released a handful of new
Viewmodifiers to help developers simplify building their app user interfaces. I will go over five of my top favorite modifiers released with sample code snippets that will help you get started.
If you want even more information on everything released and SwiftUI this year, check out the WWDC talk, what's new in SwiftUI. There you can see the SwiftUI team go over even more APIs that I didn't get a chance to mention here.
I recently downloaded Xcode 13 and built a simple app to search restaurants and coffee shops based on my location. While creating this app, I implemented many of these new view modifiers and can honestly say you'll be surprised by how easy they make doing non-trivial tasks like autocomplete. Finally, we're starting to see the true declarative power of SwiftUI.
In the past versions of SwiftUI, adding a search bar was not a trivial task. You would probably have to use a library like SwiftUIX or create a wrapper using ViewRepresentable. Both of these methods require some serious thought about tradeoffs you'll have to make in your app!
Last year, I even made a tutorial on this matter, pleading for the SwiftUI team to add a view modifier that did this for us. Happy to say they have delivered!