4
votes

In xcode 7 there is no option to retina 4 image. I am creating a simple view added background image in my xib file.I have created a image.xcassets of background image added 1x (320 * 480), 2x (640 * 960), 3x ( 1248 * 2208) resolution images. But when i am using this image set on my xib file its only showing a correct image for iphone 4 and iphone 4s. I have changed the mode as Aspectfit.After that it has started showing margins on top and bottom. Please help me.

Thanks in advance

2

2 Answers

2
votes

I guess you will need to edit the xcassets json files yourself, or find an editor that can do that for you.

The json format is open and documented by Apple

2
votes

You will have to add the lines in json file of your image. Follow the below steps:
1. Right click on the image set in images.xcassets, click on show in finder.
2. You will see Contents.json file, open this file and add below code:

{  
      "idiom" : "iphone",
      "filename" : "iphone-5.png",
      "subtype" : "retina4",
      "scale" : "2x"
},

so your final json file will look like the following:

{
 "images" : [
 {
   "idiom" : "iphone",
   "filename" : "iphone-4-normal.png",
   "scale" : "1x"
 },
 {
   "idiom" : "iphone",
   "filename" : "iphone-4-ratina.png",
   "scale" : "2x"
 },
 {
   "idiom" : "iphone",
   "filename" : "iphone-5.png",
   "subtype" : "retina4",
   "scale" : "2x"
 },
 {
   "idiom" : "iphone",
   "filename" : "iphone-6+.png",
   "scale" : "3x"
 }
 ],
 "info" : {
 "version" : 1,
 "author" : "xcode"
 }
}  

3. Save the file and close it. Now in your Xcode there will be 4 sub image set and you can drag the respective image in that.