简体   繁体   中英

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) ...

在此处输入图像描述

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...

在此处输入图像描述

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

在此处输入图像描述

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) ...

在此处输入图像描述

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)
        }

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM