1111
1212@interface ViewController ()<SVGAPlayerDelegate>
1313
14- @property (nonatomic , strong ) SVGAPlayer *aPlayer;
14+ @property (weak , nonatomic ) IBOutlet SVGAPlayer *aPlayer;
1515
1616@end
1717
@@ -22,14 +22,15 @@ @implementation ViewController
2222- (void )viewDidLoad {
2323 [super viewDidLoad ];
2424
25- self.view .backgroundColor = [UIColor blackColor ];
26- [self .view addSubview: self .aPlayer];
2725 self.aPlayer .delegate = self;
28- self.aPlayer .frame = CGRectMake (0 , 0 , 320 , 320 );
2926 self.aPlayer .loops = 0 ;
3027 self.aPlayer .clearsAfterStop = YES ;
3128 parser = [[SVGAParser alloc ] init ];
32- [parser parseWithNamed: @" mutiMask"
29+ [self onChange: nil ];
30+ }
31+
32+ - (IBAction )onChange : (id )sender {
33+ [parser parseWithNamed: @" mutiMatte"
3334 inBundle: [NSBundle mainBundle ] completionBlock: ^(SVGAVideoEntity * _Nonnull videoItem) {
3435 if (videoItem != nil ) {
3536 self.aPlayer .videoItem = videoItem;
@@ -39,46 +40,4 @@ - (void)viewDidLoad {
3940 }];
4041}
4142
42- - (void )viewWillLayoutSubviews {
43- [super viewWillLayoutSubviews ];
44- self.aPlayer .frame = CGRectMake (0 , 0 , self.view .bounds .size .width , self.view .bounds .size .height );
45- }
46-
47- - (IBAction )onChange : (id )sender {
48- NSArray *items = @[
49- @" https://github.com/yyued/SVGA-Samples/blob/master/EmptyState.svga?raw=true" ,
50- @" https://github.com/yyued/SVGA-Samples/blob/master/HamburgerArrow.svga?raw=true" ,
51- @" https://github.com/yyued/SVGA-Samples/blob/master/PinJump.svga?raw=true" ,
52- @" https://github.com/yyued/SVGA-Samples/blob/master/TwitterHeart.svga?raw=true" ,
53- @" https://github.com/yyued/SVGA-Samples/blob/master/Walkthrough.svga?raw=true" ,
54- @" https://github.com/yyued/SVGA-Samples/blob/master/angel.svga?raw=true" ,
55- @" https://github.com/yyued/SVGA-Samples/blob/master/halloween.svga?raw=true" ,
56- @" https://github.com/yyued/SVGA-Samples/blob/master/kingset.svga?raw=true" ,
57- @" https://github.com/yyued/SVGA-Samples/blob/master/posche.svga?raw=true" ,
58- @" https://github.com/yyued/SVGA-Samples/blob/master/rose.svga?raw=true" ,
59- ];
60- [UIApplication sharedApplication ].networkActivityIndicatorVisible = YES ;
61- [parser parseWithURL: [NSURL URLWithString: items[arc4random () % 10 ]]
62- completionBlock: ^(SVGAVideoEntity * _Nullable videoItem) {
63- [UIApplication sharedApplication ].networkActivityIndicatorVisible = NO ;
64- if (videoItem != nil ) {
65- self.aPlayer .videoItem = videoItem;
66- [self .aPlayer startAnimation ];
67- }
68- } failureBlock: nil ];
69- // [parser parseWithNamed:@"heartbeat" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
70- // if (videoItem != nil) {
71- // self.aPlayer.videoItem = videoItem;
72- // [self.aPlayer startAnimation];
73- // }
74- // } failureBlock:nil];
75- }
76-
77- - (SVGAPlayer *)aPlayer {
78- if (_aPlayer == nil ) {
79- _aPlayer = [[SVGAPlayer alloc ] init ];
80- }
81- return _aPlayer;
82- }
83-
8443@end
0 commit comments