Issue
I’m trying to use a CustomTabView
in a similar way to the native TabView
and I’m getting the error Protocol type 'Any' cannot conform to 'View' because only concrete types can conform to protocols
.
Possible Solution
I can solve this issue by passing in type erased views into CustomTabView
like so:
CustomTabView {
AnyView(Text("A"))
AnyView(Text("B"))
AnyView(Rectangle())
}
Desired Solution
Ideally, I’d like to be able to do the following just like the native TabView
:
CustomTabView {
Text("A")
Text("B")
Rectangle()
}
Question
How can I convert the TupleView
into an array of AnyView
so that I can use CustomTabView
in the desired way?