将 UIView 的子视图放在其 CALayer 前面?
这可能吗?基本上,我想给我的 UIView 一个子视图,并让该子视图位于视图层的前面(更具体地说,在所述层的边框前面)。
当然,我可以通过创建视图的超级视图的两个子视图(一个在另一个之上)来实现我想要的效果。但如果可能的话,我宁愿避免这种情况。
Is this possible? Basically, I want to give my UIView a subview, and have that subview be in front of the view's layer (more specifically, in front of said layer's border).
Of course I could achieve the effect I want by making two subviews of the view's superview, one on top of the other. But I'd rather avoid that if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己也找了一会儿;我不相信这是可能的。正如您所暗示的,我通过将子视图和父视图添加到同一个“容器”超级视图来解决这个问题。然后,只需对两个子视图进行排序,以便您的子视图位于另一个子视图及其边框之上。
I looked for this for a while myself; i don't believe it is possible. I solved the issue by, as you hint at, adding the subview and the parent to the same 'container' superview. Then its just a matter of ordering the two subviews, so that your subview is above the other and its border.
我用一个segue动画解决了这个问题,我需要sourceViewController位于destinationViewController前面。我必须删除 sourceViewController 才能重新嵌套它。我的代码如下所示:
I solved this with a segue animation where i needed the sourceViewController to be in front of the destinationViewController. I had to remove the sourceViewController in order to re-nest it. My code looks like this: