简体   繁体   English

iOS 6:iPhone 5中的背景imageview

[英]ios 6 : background imageview in iPhone 5

In my iphone application I am using a background image bg.png (for retina size bg@2x.png). 在我的iPhone应用程序中,我正在使用背景图片bg.png(用于视网膜尺寸bg@2x.png)。 I updated xcode to 4.5. 我将xcode更新为4.5。 Now I need to arrange the UI for fit into iPhone 5 - 4 inch display. 现在,我需要安排UI以适合iPhone 5-4英寸显示屏。 Since the frame height will become 568, I need to fix my background also having a height 568. I added a image named bg-568h@2x.png in my app. 由于帧的高度将变为568,因此我需要将背景的高度也固定为568。我在应用中添加了名为bg-568h@2x.png的图像。 But Iam not getting this image for iPhone 6 simulator in xcode. 但是我没有在xcode中为iPhone 6模拟器获取此图像。 Is there any way to get this image? 有什么办法得到这张图片吗? or how can I achieve this? 或如何实现?

Try this dynamic code.... 试试这个动态代码。

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg.png"]];

or 要么

This creates a memory leak. 这会导致内存泄漏。 Either change initWithPatternImage to colorWithPatternImage, or assign your UIColor object to a variable and properly release it: 可以将initWithPatternImage更改为colorWithPatternImage,或者将UIColor对象分配给变量并正确释放它:

UIColor *color = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg.png"]];
self.view.backgroundColor = color;
[color release];

如何将bg-568h@2x.png设置为背景图像,并将ImageView缩放比例设置为Aspect Fill?

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

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