mirror of
https://github.com/svga/SVGAPlayer-iOS.git
synced 2025-10-20 23:19:13 +08:00
lazy load maskPath.
This commit is contained in:
@@ -38,13 +38,14 @@ static SVGAParser *parser;
|
||||
}
|
||||
|
||||
- (IBAction)onChange:(id)sender {
|
||||
|
||||
NSString *named = @"rose_2.0.0";
|
||||
NSString *named = @"rose_1.5.0";
|
||||
NSLog(@"start");
|
||||
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:named ofType:@"svga"]
|
||||
options:kNilOptions
|
||||
error:NULL];
|
||||
[parser parseWithData:data
|
||||
cacheKey:named completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
NSLog(@"end");
|
||||
if (videoItem != nil) {
|
||||
self.aPlayer.videoItem = videoItem;
|
||||
[self.aPlayer startAnimation];
|
||||
|
@@ -19,6 +19,7 @@
|
||||
@property (nonatomic, assign) CGRect layout;
|
||||
@property (nonatomic, assign) CGFloat nx;
|
||||
@property (nonatomic, assign) CGFloat ny;
|
||||
@property (nonatomic, strong) NSString *clipPath;
|
||||
@property (nonatomic, strong) CALayer *maskLayer;
|
||||
@property (nonatomic, strong) NSArray *shapes;
|
||||
|
||||
@@ -61,9 +62,7 @@
|
||||
}
|
||||
NSString *clipPath = JSONObject[@"clipPath"];
|
||||
if ([clipPath isKindOfClass:[NSString class]]) {
|
||||
SVGABezierPath *bezierPath = [[SVGABezierPath alloc] init];
|
||||
[bezierPath setValues:clipPath];
|
||||
self.maskLayer = [bezierPath createLayer];
|
||||
self.clipPath = clipPath;
|
||||
}
|
||||
NSArray *shapes = JSONObject[@"shapes"];
|
||||
if ([shapes isKindOfClass:[NSArray class]]) {
|
||||
@@ -107,9 +106,7 @@
|
||||
(CGFloat)protoObject.transform.ty);
|
||||
}
|
||||
if ([protoObject.clipPath isKindOfClass:[NSString class]] && protoObject.clipPath.length > 0) {
|
||||
SVGABezierPath *bezierPath = [[SVGABezierPath alloc] init];
|
||||
[bezierPath setValues:protoObject.clipPath];
|
||||
self.maskLayer = [bezierPath createLayer];
|
||||
self.clipPath = protoObject.clipPath;
|
||||
}
|
||||
if ([protoObject.shapesArray isKindOfClass:[NSArray class]]) {
|
||||
_shapes = [protoObject.shapesArray copy];
|
||||
@@ -129,4 +126,13 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CALayer *)maskLayer {
|
||||
if (_maskLayer == nil && self.clipPath != nil) {
|
||||
SVGABezierPath *bezierPath = [[SVGABezierPath alloc] init];
|
||||
[bezierPath setValues:self.clipPath];
|
||||
_maskLayer = [bezierPath createLayer];
|
||||
}
|
||||
return _maskLayer;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user