Use Tuples In SwiftUI To Pass Just One Parameter To Any View
Daily Coding Tip 015
I often find that I want to pass 3 or more parameters to a SwiftUI view. The problem with this is that it looks pretty messy. For example, I may want to make a colour picker, which will pass bindings to a VStack of sliders and constants to a preview like this:
SliderView(red: $red, green: $green, blue: $blue)
PreviewView(red: …Keep reading with a 7-day free trial
Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.


