xcode IOS:如何前后发送图像视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28237377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:34:15  来源:igfitidea点击:

IOS: How to send an Image View back and front

iosobjective-cxcode

提问by Eduard Avetisyan

In my storyboard I have a view on which I have an ImageViewand a Button. The ImageViewis currently covering my button and I would like to put the button over the ImageView. I found similar topics which were solved by going to "Editor" -> "Arrange" -> "Send to Front", however that was done for UIViewsand this option is passive for ImageViewand Buttons.

在我的故事板中,我有一个视图,其中有ImageView一个Button. 在ImageView目前的覆盖我的按钮,我想提出的按钮在ImageView的。我发现了类似的主题,这些主题通过转到“编辑器”->“排列”->“发送到前面”来解决,但是已经完成UIViews并且此选项对于ImageViewand是被动的Buttons

So how can I send my ImageViewto background? Is the best solution for this to add an additional view only for the Buttonand then bring it to front?

那么如何将我的发送ImageView到后台?最好的解决方案是为 仅添加附加视图Button然后将其置于前面吗?

回答by Alexander Perechnev

You can rearrange your views on storyboard:

您可以在情节提要上重新排列您的视图:

enter image description here

在此处输入图片说明

First view in order will be hidden by next view.

按顺序排列的第一个视图将被下一个视图隐藏。

Maybe this options will be also useful for your running application:

也许这个选项对你正在运行的应用程序也很有用:

myImageView.layer.zPosition = -5;
myImageView.layer.zPosition = 5;

Like in HTML/CSS.

就像在 HTML/CSS 中一样。

回答by Eduard Avetisyan

The solution was to move the view components up and down in the "Document Outline" section.

解决方案是在“文档大纲”部分上下移动视图组件。

回答by Mike Gledhill

Alternatively, you could've solved the problem using the bringSubviewToFrontfunction:

或者,您可以使用以下bringSubviewToFront函数解决问题:

[self.view bringSubviewToFront:self.yourButtonControl];