在xcode 7中没有选项可以支持retina 4图片。我正在创建一个简单的视图,并在我的xib文件中添加背景图像。我已经创建了一个image.xcassets背景图像,添加了1x(320*480),2x(640*960),3x(1248*2208)分辨率图片。但是,当我在我的xib文件上使用这个图像集时,它只显示适用于iphone 4和iphone 4s的正确图像。我已经将模式改为AspectFit。然后它开始在顶部和底部显示边距。请帮助我。
提前致谢
提前致谢
您需要在图像的json文件中添加行。请按照以下步骤操作:
1. 右键单击在images.xcassets中设置的图像,点击“在Finder中显示”。
2. 您会看到Contents.json文件,请打开此文件并添加以下代码:
{
"idiom" : "iphone",
"filename" : "iphone-5.png",
"subtype" : "retina4",
"scale" : "2x"
},
因此,您的最终JSON文件将如下所示:
{
"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. 保存并关闭文件。现在在您的Xcode中将会有4个子图像集,您可以将相应的图像拖入其中。