iOS UIImageView 分层问题
我确信这个问题已经在很多地方得到了回答,但我不知道要搜索什么关键字来回答这个问题。如果有人可以将我链接到答案,那就太好了。
我不确定如何控制哪些 UIImageViews(它们都被子视图到同一视图)在视觉上覆盖其他视图。换句话说,如果我将一个 UIImageView 子视图到与另一个 UIImageView 相同的位置,则添加的第二个 UIImageView 始终覆盖第一个 UIImageView。我不确定如何在 UI 编辑器或代码中执行此操作。到目前为止,我一直按照我希望它们出现的顺序添加它们,但我不能总是这样做。特别是如果我需要将 UIImageView 设置为 IBOutlet,并且我需要它位于我以编程方式添加的所有 UIImageView 之上。
有人可以告诉我如何以编程方式执行此操作以及如何在 UI 编辑器中设置值吗?谢谢。
I am sure this question has been answered in numerous places but I have no idea what keyword to search for to answer this question. If anyone can link me to the answer that'd be great.
I'm not sure how to control which UIImageViews (which are all subviewed to the same view) cover the others visually. In other words, if I subview a UIImageView to the same location as another UIImageView, the 2nd one that was added is always covering the first one. I'm not sure how to do this either in the UI editor or in code. So far I've been adding them in the order I want them to show up but I can't always do that. Especially if I need to set UIImageView that's an IBOutlet and I need it to be on top of all the UIImageViews that I add programmatically.
Can someone show me how to do this programmatically and possibly how to set values in the UI editor? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIView 有几个 API 来处理这些问题:
有关所有这些的更多详细信息可以在 UIView 文档(UIImageView 是其子类。)
UIView has several APIs to deal with these issues:
More details on all of these can be found in the UIView documentation (of which UIImageView is a subclass.)
这是在 UIView 层 并且不特定于 UIImageViews。
可以使用以下 UIView 方法以编程方式“重新分层”视图:
要在 Interface Builder 中对 XIB 执行此操作,请重新排序此视图上列出的视图,底行是最前面的对象:
This is done at the UIView layer and is not specific to UIImageViews.
Views can be programmatically 'relayered' with the following UIView methods:
To do it to the XIB in Interface Builder, reorder the views listed on this view, bottom row is the frontmost object: