user1974368
user1974368

Reputation: 472

masking presented view controller with CAShapeLayer also mask the presenting view controller

like the titles says, i have a first view controller (VC1) that presents a second one (VC2) modaly. on VC2 i apply a resizable mask on self.view.layer.mask that changes its size with a pan gesture, but when the mask resizes i don't see VC1 behind VC2, i see just black color which is the .backgroundColor of the application's UIWindow. both self.view.clipToBounds and self.view.layer.masksToBounds are set to true on self.view of VC2. why is that? thanks

video of bug: https://youtu.be/9Kda10Sl2g8

i managed to go around it as @nguyenbao95 suggested in his comment: Add another UIView to VC2's self.view (this view is above the snapshot), then add all your content to this view. And mask this view.

i suspect that when i modaly present VC2 then VC1 is no longer visible behind VC2 until it is needed again.

Upvotes: 0

Views: 264

Answers (1)

nguyenbao95
nguyenbao95

Reputation: 31

Before you present the second VC, just take screenshot of the first VC. And then add an UIImageView with this image to the second VC.

Hope it will solves your problem

Upvotes: 1

Related Questions