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

ios – SwiftUI Sidebar Make Additional 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.predominant.bounds.width / 1.2)
                Spacer(minLength:  0)
            .background(Colour.major.opacity(self.present ? (self.darkish ? 0.05 : 0.2) : 0).edgesIgnoringSafeArea(.all))
            .onTapGesture {
                withAnimation(.default) {

What I’m attempting 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 would like so as to add a Rectangle() and calculate the additional area?



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments