如何以编程方式在iOS9中获得正确的启动映像?
我已将不同大小的图像添加到LaunchImage资源中。当我使用这个代码时如何以编程方式在iOS9中获得正确的启动映像?,ios,launchimage,Ios,Launchimage,我已将不同大小的图像添加到LaunchImage资源中。当我使用这个代码时 UIImage *launchImage = [UIImage imageNamed:@"LaunchImage"] 它返回了错误大小的launchImage,正好返回@2xPNG。当我使用iphone6 plus时,期望的图像是@3x png。 想得到正确的图像吗?经过大量搜索,我发现LaunchImages很特别,实际上不是设备上的资产目录。所有iOS设备的launchImage文件名列表如下: 发射图像-568
UIImage *launchImage = [UIImage imageNamed:@"LaunchImage"]
它返回了错误大小的launchImage,正好返回@2xPNG。当我使用iphone6 plus时,期望的图像是@3x png。
想得到正确的图像吗?经过大量搜索,我发现LaunchImages很特别,实际上不是设备上的资产目录。所有iOS设备的launchImage文件名列表如下:
- 发射图像-568h@2x.png
- 发射图像-700-568h@2x.png
- 发射图像-700-Landscape@2x~ipad.png
- 启动image-700-scape~ipad.png
- 发射图像-700-Portrait@2x~ipad.png
- 启动image-700-grait~ipad.png
- 发射图像-700@2x.png
- 发射图像-Landscape@2x~ipad.png
- 启动image横向~ipad.png
- 发射图像-Portrait@2x~ipad.png
- 启动image-grait~ipad.png
- LaunchImage.png
- LaunchImage@2x.png
- 发射图像-800-667h@2x.png(iphone6)
- 启动image-800-grait-736h@3x.png(iPhone 6 Plus肖像)
- 启动image-800-scape-736h@3x.png(iPhone 6 Plus (景观)
NSString *launchImageName;
if([UIScreen mainScreen].bounds.size.height > 667.0f) {
launchImageName = @"LaunchImage-800-736h"; // iphone6 plus
}
else if([UIScreen mainScreen].bounds.size.height > 568.0f) {
launchImageName = @"LaunchImage-800-667h"; // iphone6
}
else if([UIScreen mainScreen].bounds.size.height > 480.0f){
launchImageName = @"LaunchImage-700-568h";// iphone5/5plus
} else {
launchImageName = @"LaunchImage-700"; // iphone4 or below
}
UIImage *launchImage = [UIImage imageNamed:launchImageName];
经过大量搜索,我发现LaunchImages很特别,实际上不是设备上的资产目录。所有iOS设备的launchImage文件名列表如下:
- 发射图像-568h@2x.png
- 发射图像-700-568h@2x.png
- 发射图像-700-Landscape@2x~ipad.png
- 启动image-700-scape~ipad.png
- 发射图像-700-Portrait@2x~ipad.png
- 启动image-700-grait~ipad.png
- 发射图像-700@2x.png
- 发射图像-Landscape@2x~ipad.png
- 启动image横向~ipad.png
- 发射图像-Portrait@2x~ipad.png
- 启动image-grait~ipad.png
- LaunchImage.png
- LaunchImage@2x.png
- 发射图像-800-667h@2x.png(iphone6)
- 启动image-800-grait-736h@3x.png(iPhone 6 Plus肖像)
- 启动image-800-scape-736h@3x.png(iPhone 6 Plus (景观)
NSString *launchImageName;
if([UIScreen mainScreen].bounds.size.height > 667.0f) {
launchImageName = @"LaunchImage-800-736h"; // iphone6 plus
}
else if([UIScreen mainScreen].bounds.size.height > 568.0f) {
launchImageName = @"LaunchImage-800-667h"; // iphone6
}
else if([UIScreen mainScreen].bounds.size.height > 480.0f){
launchImageName = @"LaunchImage-700-568h";// iphone5/5plus
} else {
launchImageName = @"LaunchImage-700"; // iphone4 or below
}
UIImage *launchImage = [UIImage imageNamed:launchImageName];
为什么你不能直接设置?实际上,我想使用启动映像,而不是启动应用程序。好的。因为它已经存在于imagecassets name LaunchImage中,所以您要替换它。这样做是不可能的。然后你需要使用不同名称的同一图像。它会为不同的屏幕大小复制许多图像。为什么你不能直接设置?实际上,我想使用启动图像而不是启动应用。确定。因为它已经存在于imagecassets name LaunchImage中,所以您要替换它。这样做是不可能的。然后你需要使用不同名称的相同图像。它会复制不同屏幕大小的许多图像。但是,对于iPhone 6 Plus来说,它是有效的,你还需要包括方向。因此,肖像模式应为“LaunchImage-800-Grait-736h”。谢谢iphone-x和更新版本的“特殊”名称是什么?有人知道吗?不过,对于iphone6plus来说,它是有效的,你还需要包括方位信息。因此,肖像模式应为“LaunchImage-800-Grait-736h”。谢谢iphone-x和更新版本的“特殊”名称是什么?有人知道吗?