HomeiOS DevelopmentThe right way to make headerView with overlapping content material design in...

The right way to make headerView with overlapping content material design in SwiftUI


I want half of Header View to be coated with remaining UI. I’m utilizing header view and record in accordance with UI design and given record prime padding in (- worth) so it goes up on header view now UI appears good however after I scroll record then my header title covers with record content material.. the best way to repair it? I heard Utilizing Zstack will not be good method for UI is it right? please information me.. I attempted ChatGPT and Clude but it surely provides un comprehensible repair so I’m asking right here.

after scrolling title covers picture:

The right way to make headerView with overlapping content material design in SwiftUI

I want like this:

the content should scroll below the red line means where the list starts from that only don't want to go above the list

Code:

struct TaskList: View {
 
    @StateObject var coredataViewmodel = CoreDataViewModel()

    var physique: some View {
        NavigationStack {
            VStack {
           
                HeaderView(screenTitle: "Process Listing")
                
                ListView
                    .padding(.prime, -150)
                
                .overlay(alignment: .bottomTrailing) {
                addButton
                }
                
            }
            .background(Colour.taskBackground)
            .onAppear {
                coredataViewmodel.loadTasks()
            }

        }

    }
}

struct HeaderView: View {
    
    var screenTitle: String = ""
    var isBackButtonNeed: Bool = false
    @Surroundings(.dismiss) var dismiss
    
    var physique: some View {
        VStack {
            HStack {
                if isBackButtonNeed {
                    Button {
                        print("again tapped")
                        dismiss()
                    } label: {
                        Picture(systemName: "arrow.backward")
                            .font(.system(measurement: 24, weight: .daring))
                            .foregroundStyle(.white)
                    }
                }

                Spacer()
            }
            .padding(.horizontal)
            .padding(.vertical)

            .overlay {
                Textual content(screenTitle)
                    .font(.system(measurement: 30, weight: .daring))
                    .foregroundStyle(Colour.fieldsColour)
            }
            Spacer()
        }
        .navigationBarBackButtonHidden(true)

        .body(maxWidth: .infinity, maxHeight: 150)
        .background(
            Colour.taskTitleColour
                .ignoresSafeArea()
        )
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments