中文文档 | English
A lightweight, high-performance SVGA animation player optimized from SVGAPlayer.
Compared to the original SVGAPlayer, SVGAPlayer-Lite achieves significant performance improvements:
- ⚡️ 40-50% Lower Memory Usage - Reduced from 20MB to 12MB
- ⚡️ 40% Lower CPU Usage - Reduced from 22% to 13%
- ⚡️ 50% Faster Startup - Reduced from 185ms to 92ms
- 📦 15-20% Smaller Package Size - Removed outdated code
- 🎯 Stable 60 FPS - Optimized rendering performance
⚠️ Note: Performance metrics are measured on real iOS devices. Simulator measurements may not be accurate and should not be used for performance evaluation.
- 🚀 Lightweight implementation with optimized performance and memory usage
- 📦 CocoaPods integration support
- 🎨 Full SVGA animation format support
- 💪 High-performance rendering engine
- 🔧 Easy integration and usage
- ✅ iOS 12.0+ support
- 🔥 Perfect Swift Support - View Swift Compatibility Guide
Add the package to your project via Xcode:
- File > Add Package Dependencies
- Enter:
https://github.com/jfyGiveMeFive/SVGAPlayer-Lite.git - Select version:
1.0.7or later
Or add to your Package.swift:
dependencies: [
.package(url: "https://github.com/jfyGiveMeFive/SVGAPlayer-Lite.git", from: "1.0.7")
]Add to your Podfile:
pod 'SVGAPlayerLite'Then run:
pod install- Clone or download this repository
- Drag the
Sourcefolder into your project - Add dependencies:
- SSZipArchive (2.4.3)
- Protobuf (3.27.2)
#import <SVGAPlayerLite/SVGA.h>
// Create player
SVGAPlayer *player = [[SVGAPlayer alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[self.view addSubview:player];
// Create parser
SVGAParser *parser = [[SVGAParser alloc] init];
// Load from network
[parser parseWithURL:[NSURL URLWithString:@"https://example.com/animation.svga"]
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
if (videoItem) {
player.videoItem = videoItem;
[player startAnimation];
}
} failureBlock:^(NSError * _Nullable error) {
NSLog(@"Load failed: %@", error);
}];
// Or load from local
[parser parseWithNamed:@"animation" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
if (videoItem) {
player.videoItem = videoItem;
[player startAnimation];
}
} failureBlock:nil];import SVGAPlayerLite
// Create player
let player = SVGAPlayer(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
view.addSubview(player)
// Create parser
let parser = SVGAParser()
// Load from network
parser.parse(with: URL(string: "https://example.com/animation.svga"), completionBlock: { videoItem in
player.videoItem = videoItem
player.startAnimation()
}, failureBlock: { error in
print("Load failed: \(error)")
})
// Or load from local
parser.parse(withNamed: "animation", in: nil, completionBlock: { videoItem in
player.videoItem = videoItem
player.startAnimation()
}, failureBlock: nil)player.loops = 0; // 0 means infinite loop
player.loops = 3; // Play 3 times[player startAnimation]; // Start playback
[player pauseAnimation]; // Pause playback
[player stopAnimation]; // Stop playback
[player stepToFrame:10 andPlay:YES]; // Jump to specific frame// Replace image
UIImage *image = [UIImage imageNamed:@"replacement"];
[player setImage:image forKey:@"key" referenceLayer:nil];
// Replace text
NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"Hello"];
[player setAttributedText:text forKey:@"key"];player.delegate = self;
// Implement delegate method
- (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player {
NSLog(@"Animation finished");
}- iOS 12.0+
- Xcode 11.0+
- SSZipArchive (2.4.3)
- Protobuf (3.27.2)
Note: To ensure all users have the same dependency versions, this project uses fixed version numbers instead of version ranges.
SVGAPlayer-Lite is a lightweight version based on SVGAPlayer with the following improvements:
- Optimized memory management
- Improved rendering performance
- Simplified APIs
- Better stability
Apache License 2.0
cd SVGAPlayer-Lite
pod install
open SVGAPlayerLite.xcworkspace- Create a new Xcode project
- File > Add Package Dependencies
- Add local package: select the
SVGAPlayer-Litefolder - Link
SVGAPlayerLitelibrary to your target
Issues and Pull Requests are welcome!
- Add English documentation
- Add language switcher between Chinese and English
- Improve international accessibility
- Lock dependency versions for consistency
- SSZipArchive fixed to 2.4.3
- Protobuf fixed to 3.27.2
- Prevent compatibility issues from version drift
- Update dependency version constraints for better compatibility
- SSZipArchive updated to ~> 2.4
- Protobuf updated to ~> 3.27
- Improved dependency management strategy
- Update author email for privacy protection
- Add comprehensive Swift compatibility documentation
- Performance optimization and dependency updates
- Add CocoaPods Trunk publishing guide
- Initial release
- CocoaPods integration support
- Optimized from SVGAPlayer