You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.
I'm using SwiftGif to display animations along the UI, but with iOS 13 I found some of my animations are not displaying correctly on DarkMode, so I'd like to have trait variations as we have with UIColor:
staticvarcustomAccent:UIColor{
if #available(iOS 13,*){returnUIColor{(traitCollection:UITraitCollection)->UIColorin
if traitCollection.userInterfaceStyle ==.dark {returnMaterialUI.orange300
}else{returnMaterialUI.orange600
}}}else{returnMaterialUI.orange600
}}
I can make something similar with UIImage using this code (below), but I cannot get it to work with the Gifs.
extensionUIImage{/// Creates a dynamic image that supports displaying a different image asset when dark mode is active.staticfunc dynamicImageWith(
light makeLight:@autoclosure()->UIImage,
dark makeDark:@autoclosure()->UIImage)->UIImage{letimage=UITraitCollection(userInterfaceStyle:.light).makeImage(makeLight())
image.imageAsset?.register(makeDark(), with:UITraitCollection(userInterfaceStyle:.dark))return image
}}extensionUITraitCollection{/// Creates the provided image with traits from the receiver.func makeImage(_ makeImage:@autoclosure()->UIImage)->UIImage{varimage:UIImage!performAsCurrent{
image =makeImage()}return image
}}
Anyone have any idea on how to solve the problem?
The text was updated successfully, but these errors were encountered:
JorgeFrias
changed the title
iOS 13 support for traitCollection.userInterfaceStyle
iOS 13 support for traitCollection.userInterfaceStyle (Dark mode)
Nov 25, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
First of all, awesome extension!
I'm using SwiftGif to display animations along the UI, but with iOS 13 I found some of my animations are not displaying correctly on DarkMode, so I'd like to have trait variations as we have with
UIColor
:I can make something similar with UIImage using this code (below), but I cannot get it to work with the Gifs.
Anyone have any idea on how to solve the problem?
The text was updated successfully, but these errors were encountered: