如何将 UIView 移动到 SuperView 之外?

发布于 2025-01-02 22:35:56 字数 170 浏览 5 评论 0原文

所以,我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只有影子陪我不离不弃 2025-01-09 22:35:56

当您开始拖动视图时, 将其从 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.

倾`听者〃 2025-01-09 22:35:56

你可以使用这个方法[UIView removeFromSuperView];

you can use this method [UIView removeFromSuperView];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文