如果你不想要用LaunchScreen.storyboard
而是使用Launch Image Source
然後第一個畫面你想要拿到跟Launch Image Source的同一張圖片
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| 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 }
|