如何在 XCode 故事板编辑器中设置主视图的背景图像?

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

How to set the background image of the main view in XCode storyboard editor?

iosxcode

提问by Void

I am trying to set a background image for my main superview in the story board editor without creating another view(just for a background image). I can change the class of my main view to UIImageView, but the editor will not show me the option to specify a background image. How can I make this work?

我试图在故事板编辑器中为我的主超级视图设置背景图像而不创建另一个视图(仅用于背景图像)。我可以将主视图的类更改为 UIImageView,但编辑器不会向我显示指定背景图像的选项。我怎样才能使这项工作?

回答by Audun Kjelstrup

It is possible, but you won't get visual feedback from the storyboard. Under the Identity inspector (cmd+option+3), there is a pane for setting user-defined runtime attributes, and setting the backgroundColorto a [UIColor colorWithPatternImage:]should work just fine. I would however, for clarity, keep that sort of stuff in the viewDidLoad-method

这是可能的,但您不会从故事板中获得视觉反馈。在身份检查器 (cmd+option+3) 下,有一个用于设置用户定义的运行时属性的窗格,将backgroundColora设置为 a[UIColor colorWithPatternImage:]应该可以正常工作。然而,为了清楚起见,我会在viewDidLoad-method 中保留那种东西