How do I make my SwiftUI TabView
with a PageTabViewStyle
adjust its height to the height of the content?
I have a SwiftUI
view like follows:
struct TabViewDynamicHeight: View {
var body: some View {
VStack {
TabView {
ForEach(0..<5, id: \.self) { index in
VStack {
Text("Text \(index)")
Text("Text \(index)")
Text("Text \(index)")
}
}
}
.tabViewStyle(PageTabViewStyle())
.background(Color.red)
.fixedSize(horizontal: false, vertical: true)
}
.background(Color.blue)
}
}
This produces an output like this:
You can see, that the content of the TabView
is cut off. I'm aware, that I can remove .fixedSize
, but than the view looks like this:
I would like the TabView to respond to the height of the content. Any ideas on how to achieve that?