iOS Development

ios – SwiftUI Sidebar Make Further House 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 : .mild)
                    .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 making an attempt to resolve is to make the additional area beside the sidebar clickable (so it may be collapsed). With the present code, in all places within the display screen 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?

What's your reaction?

Leave A Reply

Your email address will not be published.