TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

zIndex of stacks

Forums > SwiftUI

Hello everyone,

Im trying to reproduce a similar case showed by Paul here: https://youtu.be/ffV_fYcFoX0?list=PLbr7dGK6lMMWW4Vo-NwSKa0sMBzYYMMra&t=2503

Basic goal: 1/ A view must be dragged all hover the screen 2/ and on top of ALL others views

Part 1/ work like a charm ! as describe in video, using zIndex to put the view moved on top of its parent.

However part 2/ is where I get in trouble with ! In fact few seconds later, https://youtu.be/ffV_fYcFoX0?list=PLbr7dGK6lMMWW4Vo-NwSKa0sMBzYYMMra&t=2543, Paul face the same problem I encounter, but bypass the case of zIndex by "disabling" the gesture on letters from the center view which is clearly BEHIND the bottom letter when dragged.

Question: How can I achieve this goal of part 2/ where the view I would like to drag to be on top of all others view displayed on the screen ?

Thanks for your help ;)

3      

Paul says at the beginning of that first snippet that the z index only applies within the same container, so you need to have all of your items in one container, I think

3      

@markbooth5457 Yes, I heard it too... :/

but it has to be a way to do something similar in order to make something like that working !

3      

@graniv I think you may get away with it by changing the z-index of the parent view of whatever you're trying to drag to be higher than the parent view of whatever you're trying to drop it over.

So if you have

Parent A <--- z-index should be 1

  • DraggableItemA <---- z-index should be 1 Parent B <-- z-index should be 0
  • DraggableItemB <-- z-index should be 0

Something like that!

3      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.