Created
May 12, 2021 08:07
-
-
Save manmal/97247dcea0bdcee92d935d926037ecac to your computer and use it in GitHub Desktop.
UIImage+LaunchImage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIImage { | |
/// Available launch images (as of 12 May 2021): | |
/// [email protected]: 750x1334 | |
/// [email protected]: 828x1792 | |
/// [email protected]: 1242x2208 | |
/// [email protected]: 1125x2436 | |
/// [email protected]: 1242x2688 | |
static var launchImage: UIImage { | |
let images: [(height: CGFloat, name: String)] = [ | |
(1334, "[email protected]"), | |
(1792, "[email protected]"), | |
(2208, "[email protected]"), | |
(2436, "[email protected]") | |
] | |
let image = images | |
.first { $0.height <= UIScreen.main.nativeBounds.height } | |
.map(\.name) | |
.map(UIImage.init(named:)) | |
return (image ?? UIImage(named: "[email protected]"))! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changing
.first(where: { $0.height <= UIScreen.main.nativeBounds.height })
to.first(where: { $0.height >= UIScreen.main.nativeBounds.height })
should get you the correct logic.