123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // LaunchAnimationView.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/7/26.
- //
- #import "LaunchAnimationView.h"
- #import <Lottie/Lottie.h>
- @interface LaunchAnimationView ()
- @property (nonatomic, strong) LOTAnimationView *loadingView;
- @property (nonatomic, strong) NSString *jsonString;
- @property (nonatomic, copy) LaunchFinishCallback callback;
- @end
- @implementation LaunchAnimationView
- - (void)launchAnimationFinish:(LaunchFinishCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (instancetype)init {
- self = [super init];
- if (self) {
- }
- return self;
- }
- - (void)configUI {
- self.backgroundColor = [UIColor whiteColor];
-
- [self setJsonName:@"launchAni.json"];
- }
- - (void)setJsonName:(NSString *)jsonName {
- self.jsonString = jsonName;
- [self addSubview:self.loadingView];
- MJWeakSelf;
- [self.loadingView playWithCompletion:^(BOOL animationFinished) {
- [weakSelf successBack];
- }];
- }
- - (void)successBack {
- if (self.callback) {
- self.callback();
- }
- }
- - (LOTAnimationView *)loadingView {
- if(_loadingView == nil) {
- //1.加载本地json
- _loadingView = [LOTAnimationView animationNamed:self.jsonString];
- //2.加载后台给的json(url)
- _loadingView.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
- _loadingView.loopAnimation = YES;
- _loadingView.contentMode = UIViewContentModeScaleAspectFill;
- _loadingView.animationSpeed = 1.0;
- _loadingView.loopAnimation = NO;
- }
- return _loadingView;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|