-
Notifications
You must be signed in to change notification settings - Fork 306
Can a gif be loaded from an asset catalog? #66
Comments
Same thing happened to me. Xcode now doesn't recognise gif files in the .xcassets folder. To solve this i made a new group called 'Gif', outside of the .xcassets folder and added my .gif files to this. Then called it in the same way; e.g. myImageView.image = UIImage.gif(name: "mygif") Worked for me! |
You could extend your extension UIImage {
public class func gif(asset: String) -> UIImage? {
if let asset = NSDataAsset(name: asset) {
return UIImage.gif(data: asset.data)
}
return nil
}
} You'll be able to load GIFs from assets based on their names using imageView.image = UIImage.gif(asset: "njoy") |
#68 is merged, closing. Feel free to open if the issue persists. |
@bahlo I am using version 1.6.1 and encountered this error. I looked in the source code that CocoaPods pulled down and I don't see the code that allows you to look up the image as an asset. Is the code not released or am I doing something wrong? Thanks so much! By putting my images in a folder outside of the asset folder I was able to load the image just fine. |
Seconded. Can a version please be released with this PR in it? Also just generally it looks like there have been quite a few changes added to SwiftGif without a release - is there any plan to release it soon @bahlo? Thanks! |
Getting
SwiftGif: This image named "njoy" does not exist
while trying
The text was updated successfully, but these errors were encountered: