Sunday, October 2, 2022
HomeiOS Developmentios - SwiftUI Sidebar Make Further Area Clickable

ios – SwiftUI Sidebar Make Further Area Clickable

I learn that Spacer() doesn’t work with onTapGesture because it requires seen/opaque views(?).

It is a snippet of my code.

         HStack {
                SideMenuView(darkish: self.$darkish, present: self.$present, navigationManager: navigationManager)
                    .preferredColorScheme(self.darkish ? .darkish : .gentle)
                    .offset(x: self.present ? 0 : -UIScreen.principal.bounds.width / 1.2)
                Spacer(minLength:  0)
            .background(Coloration.main.opacity(self.present ? (self.darkish ? 0.05 : 0.2) : 0).edgesIgnoringSafeArea(.all))
            .onTapGesture {
                withAnimation(.default) {

What I’m making an attempt to unravel is to make the additional area beside the sidebar clickable (so it may be collapsed). With the present code, all over the place within the display that doesn’t obtain enter will set off onTapGesture (Textual content labels within the sidebar, further area beside it)

Is there a view I’m lacking right here? Or do i want so as to add a Rectangle() and calculate the additional area?



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments