Created
April 20, 2020 11:58
-
-
Save krummler/4d7d852458cd8a312f627ae79053189c to your computer and use it in GitHub Desktop.
This file contains 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
// Create an asset | |
let set = UIImageAsset() | |
// Define traits to be specific for the images | |
let darkTraits = UITraitCollection(traitsFrom: [UITraitCollection(userInterfaceStyle: .dark), | |
UITraitCollection(displayScale: someDarkImage.scale)]) | |
let lightTraits = UITraitCollection(traitsFrom: [UITraitCollection(userInterfaceStyle: .light), | |
UITraitCollection(displayScale: someLightImage.scale)]) | |
// Register the images alongside the traits | |
set.register(someDarkImage, with: darkTraits) | |
set.register(someLightImage, with: lightTraits) | |
// Generated a combined image | |
let combinedImages = set.image(with: .current) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment