[英]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. 如标题所述,我有一个第一视图控制器(VC1),它提供了第二个视图控制器(VC2)模态。 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
. 在VC2我申请一个可调整大小的面膜self.view.layer.mask
与平移手势改变其大小,但在口罩大小调整我没有看到背后VC2 VC1,我看到的只是黑色这是.backgroundColor
的应用程序的UIWindow
。 both self.view.clipToBounds
and self.view.layer.masksToBounds
are set to true
on self.view
of VC2. 在VC2的self.view
, self.view.clipToBounds
和self.view.layer.masksToBounds
都设置为true
。 why is that? 这是为什么? thanks 谢谢
video of bug: https://youtu.be/9Kda10Sl2g8 错误的视频: 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. 我按照@ nguyenbao95在他的评论中的建议设法解决了这个问题:在VC2的self.view中添加另一个UIView(此视图在快照上方),然后将所有内容添加到该视图。 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. 我怀疑当我模态显示VC2时,VC1在VC2后面不再可见,直到再次需要它为止。
Before you present the second VC, just take screenshot of the first VC. 在呈现第二个VC之前,只需获取第一个VC的屏幕截图。 And then add an UIImageView with this image to the second VC. 然后将带有该图像的UIImageView添加到第二个VC。
Hope it will solves your problem 希望它能解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.