I have just created a png image that id like to use in my app as a background.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_tile.png"]];
Here is the code which sets that background that works. I just registered for the iOS dev program so now i will be able to test ad hoc on my devices. I was wondering how to ‘override’ this image so that it rasterizes well on the iPad.
The dimensions for the original photoshop jpg are about 500 height 350 width which i find fits perfectly as an iPhone background. The dimensions for an HD image i hear is on average; 1920 height and 1080 width but I am using a virtual box so my screen space is a tad meh. Anyway how to I override images for the iPad bkg?
Thanks
3
Answers
You should bundle the images for iPad as well. Now at run time you can check if the device is iPAd then you should load the images accordingly.
Using asset bundle (xcassets), you can configure different images for different iOS devices and it will load proper image at run time.
You can rename image files for different devices as mentioned below and iOS will automatically take relevant image.
If you image size is big enough, I would suggest you not use
instead use background UIImageView and set its image property.
You can use [[UIDevice currentDevice] userInterfaceIdiom] to determine whether you’re running on an iPhone/iPod touch or an iPad.
There’s often no need to determine directly whether you’re on a retina display because UIImage handles that automatically when you use imageNamed and append “@2x” to your high resolution image file names (see Supporting High-Resolution Screens in the Drawing and Printing Guide for iOS).
If you really need to know which resolution the screen has, use UIScreen’s scale method.
Hope this will help to you..