2015-10-15 90 views
4

在xcode 7中,沒有選項可以使用視網膜4圖像。我創建了一個簡單的視圖在我的xib文件中添加了背景圖片。我創建了一個背景圖片的image.xcassets,添加了1x(320 * 480),2x(640 * 960),3x(1248 * 2208)分辨率的圖片。但是,當我在我的xib文件中使用這個圖像集時,它僅顯示iphone 4和iphone 4s的正確圖像。我已經改變了Aspectfit的模式。之後,它開始在頂部和底部顯示邊距。請幫幫我。xcode 7 - 在image.xcassets中缺少對Retina 4的支持

在此先感謝

+0

檢查此鏈接:http://www.intertech.com/Blog/xcode-assets-xcassets/ – vijay

回答

2

我猜你會需要編輯xcassets JSON文件自己,或者找到一個編輯器,可以爲你做的。

JSON格式是開放的,documented by Apple

2

您必須添加線在圖像的JSON文件。請遵循以下步驟:
1.右鍵單擊images.xcassets中設置的圖像,單擊查找器中顯示。
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個子圖像集,你可以在那裏拖動相應的圖像。