set 1024*780 Image for all the iDevices

I Just started developing an Universal iOS app for which I need to set the Background image.

Instead of using 3~4 different size images for iPhone, iPhone-retina, iPhone5 , iPhone5-retina & iPad, iPad-retina , I Just want to take one Highest resolution Image (say 1024*780), Which I want to use to fit all the above mentioned devices. How???

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sfond-appz.png"]];

& it is not occupying the exact screen size for smaller devices. it is shrinking.

Please Advice!!!


If Apple suggests to use different images for each kind of display there is a specific reason, and that reason is memory.
As display size increases it increases also the memory available on the device that's because bigger images require more memory. Even if you want to resize (not stretching) them at runtime, the first time you open it will occupy that memory until you release it. The memory occupied it doesn't have to deal with the file size.
If you still want to try take a look at this library that will help you to resize (not stretch) images at runtime NYXImagesKit


I'm doing the same thing in one of my apps in the App Store. On the main menu view, I use a UIImaveView as the background and set the mode to Aspect Fit in Interface Builder. I use struts and springs to keep it aligned to the edges.

For a universal app, you'll create this UIImageView on both the iPhone and iPad story board (or .xib files) and use the same image file.

However, I still have a 2x version for retina displays. So, I use just two images to cover all devices, orientations, and resolutions.

It will consume less memory if you create a background image to fit each device, but you will obviously increase the bundle size. In my case, the goal was to keep the bundle size small (under 50 MB for cellular delivery), and I had memory to spare.

链接地址: http://www.djcxy.com/p/96688.html

上一篇: 当我在iPad上运行iPhone应用程序时,屏幕分辨率错误。 如何解决这个问题?

下一篇: 为所有iDevices设置1024 * 780图像