2 C
Canberra
Thursday, June 25, 2026

ios – Methods to make headerView with overlapping content material design in SwiftUI


I would like half of Header View to be coated with remaining UI. I’m utilizing header view and checklist in keeping with UI design and given checklist prime padding in (- worth) so it goes up on header view now UI appears good however once I scroll checklist then my header title covers with checklist content material.. repair it? I heard Utilizing Zstack just isn’t good method for UI is it appropriate? please information me.. I attempted ChatGPT and Clude but it surely offers un comprehensible repair so I’m asking right here.

after scrolling title covers picture:

here title covers with list..

I would like 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(dimension: 24, weight: .daring))
                            .foregroundStyle(.white)
                    }
                }

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

            .overlay {
                Textual content(screenTitle)
                    .font(.system(dimension: 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

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles