如何将 UIView 移动到 SuperView 之外?
所以,我在 UIScrollView 中有一个自定义 UIView。我能够检测 customUIView 中的触摸事件。我试图将 UIScrollView 之外的 UIView 拖到画布(UIView)上。但是,当它超出 SrollView 的范围时,它就隐藏在 SrollView 后面吗?我怎样才能克服这个问题?谢谢你们!
So, I have a custom UIView inside a UIScrollView. I am able to detect the touches Events in the customUIView. I am trying to drag the UIView outside the UIScrollView onto a Canvas (UIView). However, when it gets out of bounds from the SrollView, it just hides behind it? How can I overcome this? Thanks guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您开始拖动视图时, 将其从 UIScrollView 的超级视图中删除,并使其成为应用程序 Window 的子视图,并且 将其置于前面(按 z 顺序)。
但首先你需要计算(转换) 相对于窗口的拖动视图的框架,因为更改其父视图后坐标会有所不同。
When you start dragging the view, remove it from the superview that is the UIScrollView, and make it a subview of the app's Window, and bring it to front (z-order-wise).
But first you need to calculate (convert) the dragging view's frame with regards to the window, since the coordinates will be different after changing its superview.
你可以使用这个方法[UIView removeFromSuperView];
you can use this method [UIView removeFromSuperView];