sdwebimage / sdwebimagelottiecoder Goto Github PK
View Code? Open in Web Editor NEWA Lottie animation coder which use SDAnimatedImageView instead of LOTAnimationView for bitmap rendering
License: MIT License
A Lottie animation coder which use SDAnimatedImageView instead of LOTAnimationView for bitmap rendering
License: MIT License
I implemented a small caching mechanism. My code loads json and displays Lottie animations on a collection view. But when I am going back (up) it crashes.
`private let cacheKey = "StickerCache"
func cache(image: UIImage?, for urlString: String) {
let path = NSTemporaryDirectory().appending(UUID().uuidString)
let url = URL(fileURLWithPath: path)
if let imageData = image?.sd_imageData() {
try? imageData.write(to: url)
var dict = UserDefaults.standard.object(forKey: cacheKey) as? [String: String] ?? [String: String]()
dict[urlString] = path
UserDefaults.standard.setValue(dict, forKey: cacheKey)
}
}
func loadCache(urlString: String) -> UIImage? {
if let dict = UserDefaults.standard.object(forKey: cacheKey) as? [String: String] {
if let path = dict[urlString] {
if let data = try? Data(contentsOf: URL(fileURLWithPath: path)) {
let scale = UIScreen.main.scale
let option = [SDImageCoderOption.decodeThumbnailPixelSize: CGSize(width: 80 * scale,
height: 80 * scale)]
// Crashes here
return SDImageLottieCoder.shared.decodedImage(with: data, options: option)
}
}
}
return nil
}
`
It does not output anything to the console, but I guess it has something to do with json decoding. maybe you can steer me into the right direction.
How can I load lottie from dotLottieURL?
If we specify the version of librlottie to 0.2.0, everything is ok.
Add pod 'librlottie', '0.2.0'
in Podfile will fix the problem temporarily.
I can't build an example or clear project with installed pod:
'rlottiecommon.h' file not found with <angled> include; use "quotes" instead
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.