简体   繁体   English

如何将子视图拖出父视图?

[英]How can I drag a subview out of the parent view?

So in my app I have a UIImageView[1] that takes up about the top half of the screen. 因此,在我的应用中,我有一个UIImageView[1]占据了屏幕的上半部分。 I also have a TapGesture recognizer that adds a UIImageView[2] as a subview of UIImageView[1] . 我也有一个TapGesture识别器,它添加了UIImageView[2]作为UIImageView[1]的子视图。

In the bottom half of my application I have another UIImageView[3] I need the UIImageView[2] 's to be able to interact with. 在应用程序的下半部分,我还有另一个UIImageView[3]我需要UIImageView[2]才能进行交互。
However, when I drag the UIImageView[2] outside the frame of UIImageView[1] it obviously disappears. 然而,当我拖动UIImageView[2]的框外UIImageView[1]它明显消失。
I was wondering if anyone knew a way I could drag UIImageView[2] to UIImageView[3] without UIImageView[2] disappearing while still maintaining the frame of UIImageView[1] . 我想知道是否有人知道我可以将UIImageView[2]拖到UIImageView[2] UIImageView[3]而不消失UIImageView[2]同时仍保持UIImageView[1]框架的方法。

I've tried resizing UIImageView[1] to just encompass the whole screen but since I'm using Aspect Fit it centers the image and if I use the top left align thing it doesn't aspect fit it. 我尝试过调整UIImageView[1]大小以仅包含整个屏幕,但是由于我使用的是Aspect Fit,因此它将图像居中,如果我使用左上对齐,则它的外观将不适合它。

试试这个禁用子视图裁剪:

[parentView clipsToBounds:NO];

尝试以下操作将UIImageView[2]拖动到视图中的其他任何位置

[self.view addsubview: UIImageView[2]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM