ios - 如何将 iOS 应用程序窗口的背景图像居中

标签 ios background uiimage window

我一直在研究如何将应用程序的背景图像居中。这主要是为了让我能够使用方形图像来减少要存储的资源量(并在进行更改时进行更新)。

最佳答案

这是我用来实现结果的代码

//  Create the window covering the bounds of the entire screen
self.window = [ [ [ UIWindow alloc ] initWithFrame:[ [ UIScreen mainScreen ] bounds ] ] autorelease ];

//  Set the background for the game.  This will show on the flip transition.
UIImageView  *bg = [ [ UIImageView alloc ] initWithImage: [ UIImage imageNamed: @"Background.png" ] ];
bg.frame = self.window.bounds;
bg.contentMode = UIViewContentModeCenter;

[ self.window addSubview: bg ];
[ self.window sendSubviewToBack: bg ];
[ bg release ];

关于ios - 如何将 iOS 应用程序窗口的背景图像居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14581216/

相关文章:

CSS - 通过悬停改变图像,就像这样!

javascript - 如何使用链接更改背景图像

iphone - UISearchbar 取消按钮的图像

ios - 如何将 BGRA 字节转换为 UIImage 进行保存?

c++ - 使用 Xcode 的 g++ 创建动态分配的数组

objective-c - 自定义 DatePicker 的算法

php - 使用 PHP 的 proc_open + bypass_shell 在后台运行可执行文件并检索正确的 PID?

ios - CGImageCreateWithImageProvider:无效的图像尺寸:180 x 180

ios - 如何释放全局变量的内存?

ios - 如何从服务器读取Plist文件并直接使用它而不创建本地文件?