xcode 你如何在 UIImageView (Objective-C) 上显示 UILabel?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7402677/
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-14 21:55:32  来源:igfitidea点击:

How do you show UILabel over a UIImageView (Objective-C)?

iphoneobjective-cxcodeuiimageviewuilabel

提问by t3hcakeman

I am developing an iPhone app and I cannot see the UILabel I made in Interface Builder, but I can see the UIImageView I made programmatically. I am a complete noob to Objective-C so please tell me what I can do to fix this.

我正在开发一个 iPhone 应用程序,我看不到我在 Interface Builder 中制作的 UILabel,但我可以看到我以编程方式制作的 UIImageView。我完全是 Objective-C 的菜鸟,所以请告诉我我能做些什么来解决这个问题。

回答by Nekto

Drag you UILabelin IB to bottom of your stack subviews of view where your UIImageViewis placed.

拖动您UILabel在您的IB至来看你的栈子视图的底部UIImageView放置。

enter image description here

在此处输入图片说明

回答by t3hcakeman

Try adding the label after the image view :

尝试在图像视图后添加标签:

[mainView addSubview:imageView];
[mainView addSubview:label];

Also make sure the label's frame makes it visible on the screen.

还要确保标签的框架使其在屏幕上可见。

回答by Janak Nirmal

Gussing that you are adding image in view where label is existing than use following code to see the label over the image view.

猜测您是在标签存在的视图中添加图像,而不是使用以下代码在图像视图上查看标签。

[self.view addSubView:yourImageViewName];
[self.view bringSubviewToFrong:yourImageViewName];

回答by Ann

I'm not sure, but click on your xib file. On the second column on your left you'll see Object, and below there's "View" with an arrow.If you click on it(the arrow) you'll see everything you have in this View. I suppose you have Button and ImageView. They shouldn't go in this way. Change their order. If you first have Button,then ImageView, you won't see your Button,cause it's under the image.

我不确定,但请单击您的 xib 文件。在你左边的第二列你会看到对象,下面是带有箭头的“视图”。如果你点击它(箭头)你会看到你在这个视图中的所有东西。我想你有 Button 和 ImageView。他们不应该走这条路。改变他们的顺序。如果您首先拥有 Button,然后是 ImageView,您将看不到 Button,因为它在图像下方。