AnyView works, but I think a @ViewBuilder is nicer.
https://developer.apple.com/documentation/swiftui/viewbuilder
struct HeaderView: View {
@State var choices = Choices.one
@ViewBuilder
var body: some View {
switch choices {
case .two:
ChoiceTwoView(choices: choices)
default:
ChoiceOneView(choices: choices)
}
}
}
Note that there is no return statement.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: