简体   繁体   English

iPhone设置背景图片

[英]iPhone Setting A Background Image

I want to use an image as a background for my application. 我想将图像用作应用程序的背景。 I want the buttons to be over the image. 我希望按钮位于图像上方。 How is this accomplished? 如何完成的? Everytime I use image view it covers up the buttons. 每次我使用图像视图时,它都会遮盖按钮。

The image view should cover your buttons unless you are placing it higher in the list of subviews. 除非将图像视图放在子视图列表的上方,否则图像视图应覆盖按钮。 Make sure your image view subview is added first and the buttons (and all other views) will be displayed on top of it. 确保首先添加了图像视图子视图,并且按钮(和所有其他视图)将显示在其顶部。 Are you doing this in Interface Builder or manually in code? 您是在Interface Builder中还是在代码中手动进行此操作?

You could try using UIView's sendSubviewToBack method: 您可以尝试使用UIView的sendSubviewToBack方法:

UIImageView view = / init view */;
// some additional code here
mainView.addSubview(view);
// add buttons, etc...
mainView.sendSubviewToBack(view);

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

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