UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Why does animation not work when view overlapping the tabbar?

Forums > SwiftUI

I have a menu overlapping the tabbar, which is fine, but the DragGesture() doesnt seem to work, the problem is when the menu has been draged for 100 frames, it just dissapers instead of dissapering with animation. And the reason for this is because its on top of the tabbar. So my question is, how can i keep the menu of top of the tabbar, but fix the animation?

struct ContentView: View {

    // To close menu
    @ObservedObject var showMenu2 = profileMenuManager.global

    @State var viewState = CGSize.zero
    var body: some View {
        let drag = DragGesture()
            .onEnded{
                self.viewState = .zero
                if $0.translation.height > 100 {
                    withAnimation {
                        self.viewState = .zero
                        self.showMenu2.showMenuView = false
                    }
                }
        }.onChanged{value in self.viewState = value.translation}

        return GeometryReader { geometry in
            ZStack(alignment: .bottom){
                // Selection determains default tab
                Tabbar()
                if self.showMenu2.showMenuView == true {
                    profileMenuView()
                        .frame(height: geometry.size.height/2, alignment: .bottom)
                        .transition(.move(edge: .bottom)).animation(.default)
                        .offset(y: 80)
                        .offset(y: self.viewState.height)
                }
            }.gesture(drag)
        }
    }
}

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.