如何使正在拖动的对象成为前景对象
我正在开发一个应用程序,让用户将对象拖动到目标位置。到目前为止,一切都是以编程方式创建的,也称为没有故事板。我的问题是,对于可拖动对象,右侧的彩色圆圈,当拖动到目标区域上时,它们位于目标区域后面。有没有办法让它成为前景对象?
I am working on an app that has users drag objects to target locations. Everything thus far is programmatically created, aka no storyboard. My issue is that for the draggable objects, the colored circles on the right, when dragged over the target area, they are behind the target area. Is there a way for it to be the foreground object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为
bringSubviewToFront(_:)
会对您有所帮助,更多信息来自 docs一旦选择了视图,您就可以执行以下操作:
这应该使被拖动的视图成为该父级/中最顶层的视图容器视图
尝试一下,看看这是否对您的用例有帮助
如果您想要更多自定义,也就是说,您想要指定某些视图上方但其他视图下方的可拖动视图,您可以查看 insertSubview(_:aboveSubview:) 和其他一些类似的方法。
I think the
bringSubviewToFront(_:)
is what will help you here, more info on this from the docsAs soon as the view is selected, you can do something like:
This should make the view being dragged the top most view in that parent / container view
Give this is a go and see if this helps your use case
If you want more customization, that is, you want to specify the draggable views above some views but below some others, you could look at insertSubview(_:aboveSubview:) and some other similar methods.