1

I am applying a background modifier to a SwiftUI view that darkens and makes inactive the view until either: 1 the user selects options from the pop-up menu OR 2 taps on the dark-overlay to cancel modifying their profile-picture.

Currently this is working except the overlay does not darken the navigation tool-bar, only the main-view...

I tried placing the background before the tool-bar declaration - did not work, also tried applying it to each individual tool-bar item but it would only darken the individual button.

How can I apply this overlay ALSO to the toolbar?

Code and image below...


struct EditProfileMenu: View {
    
    @State private var openProfilePictureAction: Bool = false
    // ^ presents HalfActionSheet 
   
    var body: some View {
        NavigationView {
            ZStack {
                VStack {      
                    Text("CHANGE PROFILE PICTURE")
                   .onTapGesture { self.openProfilePictureAction = true }   
                } 
                .toolbar(content: {
                    // TOOL BAR BUTTONS SAVE AND CANCEL 
                })
                VStack { 
                    Spacer()
                    HalfActionSheet() .offset(y: self.openProfilePictureAction ? 0 : UIScreen.main.bounds.height)
                }
               // HOW CAN I APPLY THIS TO THE TOOLBAR?
                .background(self.openProfilePictureAction ? Color.black.opacity(0.6) : Color.clear) 
                .edgesIgnoringSafeArea(.all)
                .onTapGesture {
                    self.openProfilePictureAction = false
                }
                .edgesIgnoringSafeArea(.bottom)
            } 
        } 
    } 
}



enter image description here

  • How about using `ignoresSafeArea()`? Does that solve the problem? – West1 May 30 '21 at 15:56
  • I actually have that in my current-code but did not include it for the sake of brevity. I updated my code.. –  May 30 '21 at 15:58
  • Does this your answer? https://stackoverflow.com/a/65883272/14733292 Or https://stackoverflow.com/a/67530774/14733292 – Raja Kishan May 30 '21 at 16:30

0 Answers0