CosmicMind / Motion

A library used to create beautiful animations and transitions for iOS.

Home Page:http://cosmicmind.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transition view overlaying other views with .zPosition applied

TheSwiftyCoder opened this issue · comments

I have a background view with the following applied to it inside the home controller:
bkgd.isMotionEnabled = true bkgd.motionIdentifier = "bkgd" bkgd.transition([.spring(stiffness: 300, damping: 25), .duration(0.3), .beginWith(modifiers:[.zPosition(0)]), .useGlobalCoordinateSpace])

And inside the transition to controller I have:
bkgd.isMotionEnabled = true bkgd.motionIdentifier = "bkgd" bkgd.transition([.spring(stiffness: 300, damping: 25), .duration(0.3), .beginWith(modifiers:[.zPosition(0)]), .useGlobalCoordinateSpace])

The motion transition type is: motionTransitionType = .autoReverse(presenting: .slide(direction: .right)) and I'm using the standard self.present(vc, animated: true) to initiate the transition.

The problem: When transition the background comes to the front of the view obscuring all other elements until the transition has finished. At this point it returns to it's respective zPosition. I am using xib's instead of storyboards.

Managed to solve this by adding the following to any view obscured by the animation:

On your top views add in (along with motionIdentifer etc): transition([.beginWith(modifiers:[.zPosition(10)]), .useGlobalCoordinateSpace, .forceAnimate])

On your background view (animating): transition(.beginWith(modifiers:[.zPosition(0)]), .zPosition(0)])

Hope that helps.

Thank you for sharing your solution. I appreciate both the issue and solution. All the best!