2.1.5 code
NSArray *components = [asset.imageName componentsSeparatedByString:@"."];
image = [UIImage imageNamed:components.firstObject inBundle:asset.assetBundle compatibleWithTraitCollection:nil];
2.5.0 Code
NSString *imagePath = [asset.assetBundle pathForResource:asset.imageName ofType:nil];
image = [UIImage imageWithContentsOfFile:imagePath];
When using image inside assets catalog, pathForResource return nil in LOTLayerContainer line 164.
Can anyone help to resolve issue?
Related to comment https://github.com/airbnb/lottie-ios/issues/517#issuecomment-370622730
+1 to this. It looks like LOTLayerContainer -setImageForAsset: only tries to find images in a file directory, in the image cache, or in the assetBundle using pathForResource, the latter of which does not work with Asset catalogs. It'd be great (and not too much of a fix, I believe) if they added an extra case of just trying to use UIImage +imageNamed:inBundle:compatibleWithTraitCollection: to find images in asset catalogs.
Lottie has been completely rewritten in Swift as of 3.0 (https://github.com/airbnb/lottie-ios/pull/777)
I am closing all issues prior to this release to reduce the noise. If you continue to run into this issues or any issue with Lottie 3.0 please open a new ticket
For continued support of Lottie Objective-c please point to this branch: https://github.com/airbnb/lottie-ios/tree/lottie/objectiveC
Most helpful comment
+1 to this. It looks like
LOTLayerContainer -setImageForAsset:only tries to find images in a file directory, in the image cache, or in theassetBundleusingpathForResource, the latter of which does not work with Asset catalogs. It'd be great (and not too much of a fix, I believe) if they added an extra case of just trying to useUIImage +imageNamed:inBundle:compatibleWithTraitCollection:to find images in asset catalogs.