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
IOS: How to send an Image View back and front
提问by Eduard Avetisyan
In my storyboard I have a view on which I have an ImageView
and a Button
. The ImageView
is 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 UIViews
and this option is passive for ImageView
and Buttons
.
在我的故事板中,我有一个视图,其中有ImageView
一个Button
. 在ImageView
目前的覆盖我的按钮,我想提出的按钮在ImageView的。我发现了类似的主题,这些主题通过转到“编辑器”->“排列”->“发送到前面”来解决,但是已经完成UIViews
并且此选项对于ImageView
and是被动的Buttons
。
So how can I send my ImageView
to background? Is the best solution for this to add an additional view only for the Button
and then bring it to front?
那么如何将我的发送ImageView
到后台?最好的解决方案是为 仅添加附加视图Button
然后将其置于前面吗?
回答by Alexander Perechnev
You can rearrange your views on storyboard:
您可以在情节提要上重新排列您的视图:
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 bringSubviewToFront
function:
或者,您可以使用以下bringSubviewToFront
函数解决问题:
[self.view bringSubviewToFront:self.yourButtonControl];