GetLaunchImage.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // XYWebOnRedirectRequestURLProtocol.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/5/30.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "GetLaunchImage.h"
  9. @implementation GetLaunchImage
  10. + (UIImage *)getTheLaunchImage
  11. {
  12. CGSize viewSize = [UIScreen mainScreen].bounds.size;
  13. NSString *viewOrientation = nil;
  14. if (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) || ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait)) {
  15. viewOrientation = @"Portrait";
  16. } else {
  17. viewOrientation = @"Landscape";
  18. }
  19. NSString *launchImage = nil;
  20. NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
  21. for (NSDictionary* dict in imagesDict)
  22. {
  23. CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
  24. if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
  25. {
  26. launchImage = dict[@"UILaunchImageName"];
  27. }
  28. }
  29. return [UIImage imageNamed:launchImage];
  30. }
  31. @end