SwiftUI: Problem with 3DEffect in a ScrollView

Viewed 91

in my Projekt I have a ScrollView with some elements. When I am scrolling the elements should perform a 3DEffect. Everything works fine, but the edges of the Element (a VStack) are cut off.

At the bottom the edges are cut off.

Does anybody know the problem?

Here is my code of the ContentView():

var body: some View {
    NavigationView{
        ZStack {
            VStack{
                ScrollView(showsIndicators: false){
                    VStack(spacing: 30) {
                        ForEach(0..<4){ item in
                            GeometryReader { geometry in
                                Elemente(minY: geometry.frame(in: .global).minY, title: self.möglicheZeiten[item < self.möglicheZeiten.count ? item : 0], einstellungsFeld: item )
                            }
                            .frame(maxWidth: .infinity)
                            .frame(width: 350, height: 200)
                        }
                    }
                }
                NavigationLink(destination: TrainingView()){
                    Text("Start")
                }
                .styleButton()
            }
            .navigationBarTitle("Workout", displayMode: .automatic)
        }
    }
}

And here is the code of the Element():

var body: some View{
var minY: CGFloat

...

VStack {
    VStack(spacing: 20){
        Text("\(title)")
            .bold()

        if einstellungsFeld != 3{
            Zeiten(minuten: daten.berechneMinuten(minuten: Int(wert)), sekunden: daten.berechnenSekunden(sekunden: Int(wert)))
        }else{
            Text("Durchgänge: \(Int(daten.durchgaenge))")
        }
        Slider(value: $daten.insgesamt)
    }
    .styleSettingsBox()
    .rotation3DEffect(Angle(degrees: Double(minY/10)), axis: (x: 10, y: 0, z: 0.0))
    .scaleEffect(minY < 1.00 ? minY / 1000 + 1 : 1.00, anchor: .bottom)

}

}

Thanks in advance and sorry for my English :)

1 Answers

I solved it by giving the Vstack in the ScrollView a .frame(maxHeight: .infinty).

Related