Wahab Khan Jadon
Wahab Khan Jadon

Reputation: 1196

View got Overlapped by List Items in SwiftUI

I created a view that animate and put it on the index 0 of List with zindex(1) so its keep it self on front all the time and another view for all other index's with zindex(-1)...

enter image description here

its work fine for first time but when scroll the list or navigate to detail of list item the second view with zindex(-1) overlap the first view ...

enter image description here

above image show how it suppose to work all the time ...

enter image description here

but this is what happen when after came back from detail of some specific index item ... its cover the first View which have zindex(1) ...

enter image description here

And this is what happened when scroll the list ... all the other views overlap the first view ...

Here is the code

        NavigationView{
                
                List(0 ..< 10) { item in
                    if (item == 0) {
                        Spacer()
                         TasiMarketCard()
                            .padding(.top)
                            .zIndex(1)
                            .onTapGesture {
                                self.isBlur.toggle()
                        }
                        
                    }else {
                        NavigationLink(destination: Text("1")){
                         HomeItem()
                            .zIndex(-1)
                        }
                    }
                    }
                .navigationBarTitle("Home")
                .blur(radius: self.isBlur ? 10 : 0)
        }

Upvotes: 1

Views: 832

Answers (1)

Asperi
Asperi

Reputation: 258247

Just by code reading... try zIndex in different place

NavigationLink(destination: Text("1")){
   HomeItem()
}.zIndex(-1)      // << here !!

Upvotes: 0

Related Questions