Resize, or "sink" into navigation bar effect in SwiftUI

Viewed 99

I have the following code below:

ZStack {
        
    VStack {
        
        NavigationView {
        
            VStack() {
                
                Spacer()

                image?
                    .resizable()
                    .clipShape(Circle())
                    .aspectRatio(contentMode: .fill)
                    .frame(width: 160, height: 160)
                    .overlay(Circle().stroke(Color.white, lineWidth: 4)) 
                    .overlay(
                        CameraButtonView(showActionSheet: $showActionSheet)
                            .offset(x: 50, y: 65)
                    )
                    .shadow(radius: 10)
                
                Form {

                    ....

                }

            }
            
        }
        .environment(\.horizontalSizeClass, .compact)
        
    }

}

in essence it pretty simplistic were the above portion is an image with the camera button so that users can either select from camera roll or take a picture, which will be displayed by the image, and the rest is a form when the user will be able to fill in the form accrodingly.

What I have been trying to do is make the top part of the view (the image portion) scroll up or if possible scroll/sink into the navigation bar (almost like in the iphone contacts app), when the user starts to scroll the form portion of the view.

Currently the form portion scrolls under the image portion, which as you can imagine take a good portion of the view, so hiding that top image portion would make it easier to fill in the rest of the form.

Has anyone been able to do so in SwiftUI?

0 Answers
Related