forked from svga/SVGAPlayer-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVGAImageView.m
More file actions
49 lines (42 loc) · 1.19 KB
/
SVGAImageView.m
File metadata and controls
49 lines (42 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// SVGAImageView.m
// SVGAPlayer
//
// Created by 崔明辉 on 2017/10/17.
// Copyright © 2017年 UED Center. All rights reserved.
//
#import "SVGAImageView.h"
#import "SVGAParser.h"
static SVGAParser *sharedParser;
@implementation SVGAImageView
+ (void)load {
sharedParser = [SVGAParser new];
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
_autoPlay = YES;
}
return self;
}
- (void)setImageName:(NSString *)imageName {
_imageName = imageName;
if ([imageName hasPrefix:@"http://"] || [imageName hasPrefix:@"https://"]) {
[sharedParser parseWithURL:[NSURL URLWithString:imageName] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
[self setVideoItem:videoItem];
if (self.autoPlay) {
[self startAnimation];
}
} failureBlock:nil];
}
else {
[sharedParser parseWithNamed:imageName inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
[self setVideoItem:videoItem];
if (self.autoPlay) {
[self startAnimation];
}
} failureBlock:nil];
}
}
@end