我在
我阅读了这个答案:
Images.xcassets
中使用LaunchImage.launchimage
管理启动图像。但我也想在应用程序内部使用启动图像。我阅读了这个答案:
所以,我使用了这段代码:文档说明UIImage上的imageNamed:方法应该会自动神奇地选择正确的版本。
UIImageView *backImage = [UIImageView new];
backImage.image = [UIImage imageNamed:@"LaunchImage"];
在使用 iPhone 4、5、6 和 6+ 时,它能够正常工作并获取正确的启动图像,但是在 iPad retina 上工作时,它返回 LaunchImage-700@2x.png
,这是 iPhone 4s 的启动图像 640 x 960 像素
那么我该如何通过编程访问 iPad 的正确启动图像呢?
LaunchImage
文件夹中 Contents.json
的内容。
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "LaunchImage-800-Portrait-736h@3x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "LaunchImage-800-667h@2x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "LaunchImage-700-568h@2x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700-568h@2x.png",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Images.xcassets
中的LaunchImage.launchimage
。 - MujtabaFRLaunchImage-700-Portrait~ipad.png
重命名为LaunchImage-700~ipad.png
并编辑 Contents.json,仍然返回 iPhone 4s 启动图像。 - MujtabaFR