iOS 7 / Xcode 5:以编程方式访问设备启动图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19410066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS 7 / Xcode 5: Access device launch images programmatically
提问by Timm
Is there any way to use the apps LaunchImage as a background in an universal iOS app without putting the same image resources in multiple places?
有没有办法在通用 iOS 应用程序中使用应用程序 LaunchImage 作为背景,而无需将相同的图像资源放在多个位置?
I wasn't able to access the LaunchImage
files in Images.xcassets
, so I created two new Image Sets "Background Portrait" and "Background Landscape" (since there seems to be no way to put landscape and portrait images into the same set).
我无法访问 中的LaunchImage
文件Images.xcassets
,因此我创建了两个新的图像集“背景肖像”和“背景风景”(因为似乎无法将风景和肖像图像放入同一组)。
While this workaround does the jobs, I would hate to include every image into the app twice. This also has a high maintenance cost.
虽然这种解决方法可以完成工作,但我不想将每个图像都包含在应用程序中两次。这也有很高的维护成本。
Any advice on how to access the LaunchImage for the current device is appreciated.
感谢有关如何访问当前设备的 LaunchImage 的任何建议。
GCOLaunchImageTransitionmust have done the job for iOS < 7.
GCOLaunchImageTransition必须为 iOS < 7 完成这项工作。
回答by John Erck
You can copy/paste the following code to load your app's launch image at runtime:
您可以复制/粘贴以下代码以在运行时加载应用的启动图像:
// Load launch image
NSString *launchImageName;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
if ([UIScreen mainScreen].bounds.size.height == 480) launchImageName = @"[email protected]"; // iPhone 4/4s, 3.5 inch screen
if ([UIScreen mainScreen].bounds.size.height == 568) launchImageName = @"[email protected]"; // iPhone 5/5s, 4.0 inch screen
if ([UIScreen mainScreen].bounds.size.height == 667) launchImageName = @"[email protected]"; // iPhone 6, 4.7 inch screen
if ([UIScreen mainScreen].bounds.size.height == 736) launchImageName = @"[email protected]"; // iPhone 6+, 5.5 inch screen
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if ([UIScreen mainScreen].scale == 1) launchImageName = @"LaunchImage-700-Portrait~ipad.png"; // iPad 2
if ([UIScreen mainScreen].scale == 2) launchImageName = @"LaunchImage-700-Portrait@2x~ipad.png"; // Retina iPads
}
self.launchImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:launchImageName]];
回答by Matthew Burke
You can use the launch images without having to include them twice. The key is that when you use an asset catalog, the file names of the images that are included in the app bundle are (sort of) standardized and may not be related to what you've named the original files.
您可以使用启动图像而不必包含它们两次。关键是,当您使用资产目录时,应用程序包中包含的图像的文件名是(某种程度上)标准化的,并且可能与您为原始文件命名的内容无关。
In particular, when you use the LaunchImage image set, the files that end up in the application bundle have names like
特别是,当您使用 LaunchImage 图像集时,最终出现在应用程序包中的文件的名称类似于
- LaunchImage.png
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- LaunchImage-700-Landscape@2x~ipad.png
- 启动图片.png
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- LaunchImage-700-Landscape@2x~ipad.png
etc. Note, in particular, they are not named Default.png
or any variation of that. Even if that's what you called the files. Once you've dropped them in one of the wellsin the asset catalog, they come out the other end with a standard name.
等等。请特别注意,它们没有被命名Default.png
或任何变体。即使这就是你所说的文件。一旦您将它们放入资产目录中的一个井中,它们就会以标准名称从另一端出来。
So [UIImage imageNamed:@"Default"]
won't work because there is no such file in the app bundle. However, [UIImage imageNamed:@"LaunchImage"]
will work (assuming you've filled either the iPhone Portrait 2x well or the pre iOS7iPhone Portrait 1x well).
所以[UIImage imageNamed:@"Default"]
不会工作,因为应用程序包中没有这样的文件。但是,[UIImage imageNamed:@"LaunchImage"]
会起作用(假设您已经填充了 iPhone Portrait 2x 或iOS7 之前的iPhone Portrait 1x)。
The documentation indicates that the imageNamed:
method on UIImage
should auto-magically select the correct version, but I think this only applies to image sets other than the launch image--at least I've not gotten it to work quite correctly (could just be me not doing something right).
文档表明该imageNamed:
方法UIImage
应该自动神奇地选择正确的版本,但我认为这仅适用于启动图像以外的图像集 - 至少我没有让它工作得非常正确(可能只是我没有做正确的事)。
So depending on your exact circumstances, you might need to do a little trial and error to get the correct file name. Build and run the app in the simulator and then you can always look in the appropriate subdirectory of ~/Library/Application Support/iPhone Simulator
to verify what the actual file names in the app bundle are.
因此,根据您的具体情况,您可能需要反复试验才能获得正确的文件名。在模拟器中构建并运行应用程序,然后您可以随时查看 的适当子目录~/Library/Application Support/iPhone Simulator
以验证应用程序包中的实际文件名是什么。
But again, the main point is that there is no need to include duplicates of the image files and you don't need to make any adjustments to the Copy Bundle Resources
build phase.
但同样,重点是不需要包含图像文件的副本,也不需要对Copy Bundle Resources
构建阶段进行任何调整。
回答by Daniel Witurna
Most answers require to create an image name depending on device type, scale, size etc. But as Matthew Burke pointed out, each image inside the launch image catalog will be renamed to "LaunchImage*" and therefore we are able to iterate through our launch images and find the (for the current device) appropriate image. In Objective-C it could look like this:
大多数答案都需要根据设备类型、比例、大小等创建图像名称。但正如 Matthew Burke 指出的那样,启动图像目录中的每个图像都将重命名为“LaunchImage*”,因此我们能够迭代我们的启动图像并找到(对于当前设备)合适的图像。在 Objective-C 中,它可能是这样的:
NSArray *allPngImageNames = [[NSBundle mainBundle] pathsForResourcesOfType:@"png"
inDirectory:nil];
for (NSString *imgName in allPngImageNames){
// Find launch images
if ([imgName containsString:@"LaunchImage"]){
UIImage *img = [UIImage imageNamed:imgName];
// Has image same scale and dimensions as our current device's screen?
if (img.scale == [UIScreen mainScreen].scale && CGSizeEqualToSize(img.size, [UIScreen mainScreen].bounds.size)) {
NSLog(@"Found launch image for current device %@", img.description);
break;
}
}
}
(Please note that this code uses the "containsString" method introduced with iOS 8. For previous iOS versions use "rangeOfString")
(请注意,此代码使用了 iOS 8 引入的“containsString”方法。对于之前的 iOS 版本,请使用“rangeOfString”)
回答by Simo
A Swift version of the excellent answerby Daniel Witurna that doesn't require checking against a list of all known device types or orientations.
Daniel Witurna的优秀答案的Swift 版本,不需要检查所有已知设备类型或方向的列表。
func appLaunchImage() -> UIImage? {
let allPngImageNames = Bundle.main.paths(forResourcesOfType: "png", inDirectory: nil)
for imageName in allPngImageNames
{
// make sure that the image name contains the string 'LaunchImage' and that we can actually create a UIImage from it.
guard
imageName.contains("LaunchImage"),
let image = UIImage(named: imageName)
else { continue }
// if the image has the same scale AND dimensions as the current device's screen...
if (image.scale == UIScreen.main.scale) && (image.size.equalTo(UIScreen.main.bounds.size))
{
return image
}
}
return nil
}
回答by ZYiOS
Below is the result when I test in iOS 7.0+, only portrait oritation:
下面是我在 iOS 7.0+ 上测试时的结果,只有竖屏:
3.5 inch screen: [email protected]
4.0 inch screen: [email protected]
4.7 inch screen: [email protected]
5.5 inch screen: [email protected]
iPad2 : LaunchImage-700-Portrait~ipad.png
Retina iPads : LaunchImage-700-Portrait@2x~ipad.png
回答by Lavare
Info.plist
in bundle contains launch image information, including the name of launch image.
Info.plist
in bundle 包含启动镜像信息,包括启动镜像的名称。
Objective-C:
目标-C:
- (UIImage *)getCurrentLaunchImage {
CGSize screenSize = [UIScreen mainScreen].bounds.size;
NSString *interfaceOrientation = nil;
if (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) ||
([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait)) {
interfaceOrientation = @"Portrait";
} else {
interfaceOrientation = @"Landscape";
}
NSString *launchImageName = nil;
NSArray *launchImages = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
for (NSDictionary *launchImage in launchImages) {
CGSize launchImageSize = CGSizeFromString(launchImage[@"UILaunchImageSize"]);
NSString *launchImageOrientation = launchImage[@"UILaunchImageOrientation"];
if (CGSizeEqualToSize(launchImageSize, screenSize) &&
[launchImageOrientation isEqualToString:interfaceOrientation]) {
launchImageName = launchImage[@"UILaunchImageName"];
break;
}
}
return [UIImage imageNamed:launchImageName];
}
Swift 4:
斯威夫特 4:
func getCurrentLaunchImage() -> UIImage? {
guard let launchImages = Bundle.main.infoDictionary?["UILaunchImages"] as? [[String: Any]] else { return nil }
let screenSize = UIScreen.main.bounds.size
var interfaceOrientation: String
switch UIApplication.shared.statusBarOrientation {
case .portrait,
.portraitUpsideDown:
interfaceOrientation = "Portrait"
default:
interfaceOrientation = "Landscape"
}
for launchImage in launchImages {
guard let imageSize = launchImage["UILaunchImageSize"] as? String else { continue }
let launchImageSize = CGSizeFromString(imageSize)
guard let launchImageOrientation = launchImage["UILaunchImageOrientation"] as? String else { continue }
if
launchImageSize.equalTo(screenSize),
launchImageOrientation == interfaceOrientation,
let launchImageName = launchImage["UILaunchImageName"] as? String {
return UIImage(named: launchImageName)
}
}
return nil
}
回答by Jason Cabot
A concise function in Swift for getting the launch image name at runtime:
Swift 中用于在运行时获取启动图像名称的简洁函数:
func launchImageName() -> String {
switch (UI_USER_INTERFACE_IDIOM(), UIScreen.mainScreen().scale, UIScreen.mainScreen().bounds.size.height) {
case (.Phone, _, 480): return "[email protected]"
case (.Phone, _, 568): return "[email protected]"
case (.Phone, _, 667): return "[email protected]"
case (.Phone, _, 736): return "[email protected]"
case (.Pad, 1, _): return "LaunchImage-700-Portrait~ipad.png"
case (.Pad, 2, _): return "LaunchImage-700-Portrait@2x~ipad.png"
default: return "LaunchImage"
}
}
回答by guido
Matthew Burke's answer is the correct answer. Below is the code I'm using to get this working for iOS9 / Xcode7, building an app for iOS7 and up, for iPhone and iPad, landscape allowed.
马修伯克的答案是正确的答案。下面是我用来让它在 iOS9/Xcode7 上运行的代码,为 iOS7 及更高版本构建一个应用程序,为 iPhone 和 iPad,允许横向。
First, to elaborate a bit more: In iOS8 / Xcode6, if you were using a storyboard Launch Screen File, on app startup, the app would create 2 images (one portrait, one landscape) of that launch screen file in the correct resolution for your device and you were able to get that image from the file path. (I believe it was stored in Library/LaunchImage folder).
首先,详细说明一下:在 iOS8 / Xcode6 中,如果您使用的是故事板启动屏幕文件,则在应用程序启动时,应用程序将以正确的分辨率创建该启动屏幕文件的 2 个图像(一个纵向,一个横向)您的设备,并且您能够从文件路径中获取该图像。(我相信它存储在 Library/LaunchImage 文件夹中)。
However in iOS9/XCode 7 this image is not created anymore (although a snapshot is taken in the snapshots folder, but that has a undescriptive name that changes all the time), so if you want to use your LaunchImage somewhere else in your code, you'll have to use a Launch Image Source (through asset catalog preferably, because of App Thinning). Now, as Matthew Burke is explaining you can't get to that image just by doing:
然而,在 iOS9/XCode 7 中,不再创建此图像(尽管快照是在快照文件夹中拍摄的,但其名称不具描述性且一直在更改),因此如果您想在代码中的其他位置使用 LaunchImage,您必须使用启动图像源(最好通过资产目录,因为 App Thinning)。现在,正如 Matthew Burke 所解释的那样,您无法仅通过执行以下操作来获得该图像:
let launchImage = UIImage(named: "LaunchImage")
Even though the image name in your asset catalog is LaunchImage, Xcode/iOS9 won't let you.
即使您的资产目录中的图像名称是 LaunchImage,Xcode/iOS9 也不会让您这样做。
Luckily you don't have to include your launch images again in your asset catalog. I'm saying luckily because that would mean about a 20MB increase of your App Download size if you're making an app for all devices.
幸运的是,您不必在资产目录中再次包含启动图像。我说幸运的是,如果您要为所有设备制作应用程序,这意味着您的应用程序下载大小会增加大约 20MB。
So, how to get to those launch images than? Well, here are the steps:
那么,如何获得那些启动图像呢?嗯,这里是步骤:
- Create your launch images and put them in your asset catalog. Name of the images is not important.
- Make sure your Launch Screen File (under your target's general settings) is empty and remove your app from your device and simulator. (just deleting the filename and re-running won't do it, you'll have to remove your app first)
- Run your app in the simulator and go to the ~/Library/Application Support/iPhone Simulator folder and find your app there. (It's a bit of a hassle as the folder names are indescriptive.) Show the package content for your .app file and in there you'll see several image files starting with "LaunchImage- ..." In my case there were 9 images as I'm making an app for iPhone and iPad for iOS7 and up.
Then, in your code you'll need to determine what device your app is running on and if it's in portrait or landscape and then decide which image to use. To make this a bit easier I used this framework: https://github.com/InderKumarRathore/DeviceGuru. Be ware, it didn't include the latest devices yet (iPhone 6s and iPhone 6s plus) so you'll have to add a line in his swift file for that. Then, put below piece of code in the vc where you want your launchImage and there you go:
func launchImage() -> UIImage? { if let launchImageName = launcheImageName() { print(launchImageName) return UIImage(named: launchImageName) } else { print("no launch image") return nil } } func launcheImageName() -> String? { let HD35 = "[email protected]" let HD40 = "LaunchImage-700-568h@2x" let HD47 = "[email protected]" var HD55 = "[email protected]" var padHD = "LaunchImage-700-Portrait@2x~ipad.png" var pad = "LaunchImage-700-Portrait~ipad.png" if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft || UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight { HD55 = "[email protected]" padHD = "LaunchImage-700-Landscape@2x~ipad.png" pad = "LaunchImage-700-Landscape~ipad.png" } let hardware = hardwareString() if (hardware == "iPhone1,1") { return HD35 } if (hardware == "iPhone1,2") { return HD35 } if (hardware == "iPhone2,1") { return HD35 } if (hardware == "iPhone3,1") { return HD35 } if (hardware == "iPhone3,2") { return HD35 } if (hardware == "iPhone3,3") { return HD35 } if (hardware == "iPhone4,1") { return HD35 } if (hardware == "iPhone5,1") { return HD40 } if (hardware == "iPhone5,2") { return HD40 } if (hardware == "iPhone5,3") { return HD40 } if (hardware == "iPhone5,4") { return HD40 } if (hardware == "iPhone6,1") { return HD40 } if (hardware == "iPhone6,2") { return HD40 } if (hardware == "iPhone7,1") { return HD55 } if (hardware == "iPhone7,2") { return HD47 } if (hardware == "iPhone8,1") { return HD55 } if (hardware == "iPhone8,2") { return HD47 } if (hardware == "iPod1,1") { return HD35 } if (hardware == "iPod2,1") { return HD35 } if (hardware == "iPod3,1") { return HD35 } if (hardware == "iPod4,1") { return HD35 } if (hardware == "iPod5,1") { return HD40 } if (hardware == "iPad1,1") { return pad } if (hardware == "iPad1,2") { return pad } if (hardware == "iPad2,1") { return pad } if (hardware == "iPad2,2") { return pad } if (hardware == "iPad2,3") { return pad } if (hardware == "iPad2,4") { return pad } if (hardware == "iPad2,5") { return pad } if (hardware == "iPad2,6") { return pad } if (hardware == "iPad2,7") { return pad } if (hardware == "iPad3,1") { return padHD } if (hardware == "iPad3,2") { return padHD } if (hardware == "iPad3,3") { return padHD } if (hardware == "iPad3,4") { return padHD } if (hardware == "iPad3,5") { return padHD } if (hardware == "iPad3,6") { return padHD } if (hardware == "iPad4,1") { return padHD } if (hardware == "iPad4,2") { return padHD } if (hardware == "iPad4,3") { return padHD } if (hardware == "iPad4,4") { return padHD } if (hardware == "iPad4,5") { return padHD } if (hardware == "iPad4,6") { return padHD } if (hardware == "iPad4,7") { return padHD } if (hardware == "iPad4,8") { return padHD } if (hardware == "iPad5,3") { return padHD } if (hardware == "iPad5,4") { return padHD } if (hardware == "i386") { return HD55 } if (hardware == "x86_64") { return HD55 } if (hardware.hasPrefix("iPhone")) { return HD55 } if (hardware.hasPrefix("iPod")) { return HD55 } if (hardware.hasPrefix("iPad")) { return padHD } //log message that your device is not present in the list logMessage(hardware) return nil }
- 创建您的启动图像并将它们放入您的资产目录中。图像的名称并不重要。
- 确保您的启动屏幕文件(在目标的常规设置下)为空,并从您的设备和模拟器中删除您的应用程序。(只是删除文件名并重新运行不会这样做,您必须先删除您的应用程序)
- 在模拟器中运行您的应用程序并转到 ~/Library/Application Support/iPhone Simulator 文件夹并在那里找到您的应用程序。(这有点麻烦,因为文件夹名称不明确。)显示 .app 文件的包内容,在那里你会看到几个以“LaunchImage-...”开头的图像文件在我的例子中有 9 个图像因为我正在为 iOS7 及更高版本的 iPhone 和 iPad 制作应用程序。
然后,在您的代码中,您需要确定您的应用程序在什么设备上运行以及它是纵向还是横向,然后决定使用哪个图像。为了让这更容易一些,我使用了这个框架:https: //github.com/InderKumarRathore/DeviceGuru。请注意,它尚未包含最新的设备(iPhone 6s 和 iPhone 6s plus),因此您必须为此在他的 swift 文件中添加一行。然后,将下面的代码放在你想要 launchImage 的 vc 中,然后就可以了:
func launchImage() -> UIImage? { if let launchImageName = launcheImageName() { print(launchImageName) return UIImage(named: launchImageName) } else { print("no launch image") return nil } } func launcheImageName() -> String? { let HD35 = "[email protected]" let HD40 = "LaunchImage-700-568h@2x" let HD47 = "[email protected]" var HD55 = "[email protected]" var padHD = "LaunchImage-700-Portrait@2x~ipad.png" var pad = "LaunchImage-700-Portrait~ipad.png" if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft || UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight { HD55 = "[email protected]" padHD = "LaunchImage-700-Landscape@2x~ipad.png" pad = "LaunchImage-700-Landscape~ipad.png" } let hardware = hardwareString() if (hardware == "iPhone1,1") { return HD35 } if (hardware == "iPhone1,2") { return HD35 } if (hardware == "iPhone2,1") { return HD35 } if (hardware == "iPhone3,1") { return HD35 } if (hardware == "iPhone3,2") { return HD35 } if (hardware == "iPhone3,3") { return HD35 } if (hardware == "iPhone4,1") { return HD35 } if (hardware == "iPhone5,1") { return HD40 } if (hardware == "iPhone5,2") { return HD40 } if (hardware == "iPhone5,3") { return HD40 } if (hardware == "iPhone5,4") { return HD40 } if (hardware == "iPhone6,1") { return HD40 } if (hardware == "iPhone6,2") { return HD40 } if (hardware == "iPhone7,1") { return HD55 } if (hardware == "iPhone7,2") { return HD47 } if (hardware == "iPhone8,1") { return HD55 } if (hardware == "iPhone8,2") { return HD47 } if (hardware == "iPod1,1") { return HD35 } if (hardware == "iPod2,1") { return HD35 } if (hardware == "iPod3,1") { return HD35 } if (hardware == "iPod4,1") { return HD35 } if (hardware == "iPod5,1") { return HD40 } if (hardware == "iPad1,1") { return pad } if (hardware == "iPad1,2") { return pad } if (hardware == "iPad2,1") { return pad } if (hardware == "iPad2,2") { return pad } if (hardware == "iPad2,3") { return pad } if (hardware == "iPad2,4") { return pad } if (hardware == "iPad2,5") { return pad } if (hardware == "iPad2,6") { return pad } if (hardware == "iPad2,7") { return pad } if (hardware == "iPad3,1") { return padHD } if (hardware == "iPad3,2") { return padHD } if (hardware == "iPad3,3") { return padHD } if (hardware == "iPad3,4") { return padHD } if (hardware == "iPad3,5") { return padHD } if (hardware == "iPad3,6") { return padHD } if (hardware == "iPad4,1") { return padHD } if (hardware == "iPad4,2") { return padHD } if (hardware == "iPad4,3") { return padHD } if (hardware == "iPad4,4") { return padHD } if (hardware == "iPad4,5") { return padHD } if (hardware == "iPad4,6") { return padHD } if (hardware == "iPad4,7") { return padHD } if (hardware == "iPad4,8") { return padHD } if (hardware == "iPad5,3") { return padHD } if (hardware == "iPad5,4") { return padHD } if (hardware == "i386") { return HD55 } if (hardware == "x86_64") { return HD55 } if (hardware.hasPrefix("iPhone")) { return HD55 } if (hardware.hasPrefix("iPod")) { return HD55 } if (hardware.hasPrefix("iPad")) { return padHD } //log message that your device is not present in the list logMessage(hardware) return nil }
回答by Saikiran K
Here is the modified code based on Daniel Witurna solution. This code snippet uses predicate to filter the launch image name from the list of bundle images. Predicate will potentially avoid number of loops to filter the launch image from an array of image paths.
这是基于 Daniel Witurna 解决方案的修改后的代码。此代码片段使用谓词从捆绑图像列表中过滤启动图像名称。Predicate 将潜在地避免从图像路径数组中过滤启动图像的循环次数。
-(NSString *)getLaunchImageName{
NSArray *allPngImageNames = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];
NSString *expression=[NSString stringWithFormat:@"SELF contains '%@'",@"LaunchImage"];
NSArray *res = [allPngImageNames filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:expression]];
NSString *launchImageName;
for (launchImageName in res){
{
UIImage *img = [UIImage imageNamed:launchImageName];
// Has image same scale and dimensions as our current device's screen?
if (img.scale == [UIScreen mainScreen].scale && CGSizeEqualToSize(img.size, [UIScreen mainScreen].bounds.size)) {
NSLog(@"Found launch image for current device %@", img.description);
break;
}
}
}
return launchImageName; }
回答by apouche
Another more modern and elegant solution based on the excellent answerby Daniel:
另一个更现代、更优雅的解决方案基于Daniel的出色回答:
extension UIImage {
static var launchImage: UIImage? {
let pngs = Bundle.main.paths(forResourcesOfType: "png", inDirectory: nil)
return pngs
.filter({let myLaunchImage = UIImage.launchImage
.contains("LaunchImage")})
.compactMap({UIImage(named: ##代码##)})
.filter({##代码##.size == UIScreen.main.bounds.size})
.first
}
}
That way you can just write:
这样你就可以写:
##代码##