我一直在研究如何将应用的背景图像居中。这主要是为了让我使用方形图像来减少要存储的资源量(并在进行更改时进行更新)。
答案 0 :(得分:1)
这是我用来实现结果的代码
// 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 ];