简体   繁体   English

界面构建器中是否可以为常规UIView设置图像?

[英]is there an option in interface builder to set an image for a regular UIView?

UntiL now I only needed bg image, but now I want it also for a regular view that I have, but I want to do in from the interface builder, same as for buttons.. 直到现在我只需要bg图像,但是现在我也希望它具有我所拥有的常规视图,但是我想从界面构建器中进行操作,就像按钮一样。

thanks 谢谢

In a word, no. 一言以蔽之。

You can put an image view behind a regular view, and un-check "opaque" on the view. 您可以将图像视图放置在常规视图之后,并在视图上取消选中“不透明”。

You can write code to load an image into a layer and add it to a view. 您可以编写代码以将图像加载到图层中并将其添加到视图中。

You can subclass UIView and either add an image view inside it, or override drawRect and draw an image in the background. 您可以继承UIView并在其中添加图像视图,或者重写drawRect并在后台绘制图像。

But there is no way to put an image into a vanilla UIView in IB. 但是无法将图像放入IB中的普通UIView中。

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

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