动画渲染库Lottie
文档地址 : http://airbnb.io/lottie/ios.html#installing-lottie
<一> 直接播放动画 ,LOTAnimationView一些属性也挺实用的
有下面这几种OC用法:(只显示, 不做任何的操作)
LOTAnimationView *animation = [LOTAnimationView animationNamed:@"Lottie"]; [self.view addSubview:animation]; [animation playWithCompletion:^(BOOL animationFinished) {// Do Something }];
LOTAnimationView *animation = [LOTAnimationView animationNamed:@"Lottie" inBundle:[NSBundle YOUR_BUNDLE]]; [self.view addSubview:animation]; [animation playWithCompletion:^(BOOL animationFinished) { // Do Something }];
LOTAnimationView *animation = [[LOTAnimationView alloc] initWithContentsOfURL:[NSURL URLWithString:URL]]; [self.view addSubview:animation];
CGPoint translation = [gesture getTranslationInView:self.view]; CGFloat progress = translation.y / self.view.bounds.size.height; animationView.animationProgress = progress;
[lottieAnimation playFromProgress:0.25 toProgress:0.5 withCompletion:^(BOOL animationFinished) { // Do Something }];
有下面这几种Swift用法
letanimationView=LOTAnimationView(name:"LottieLogo")self.view.addSubview(animationView)animationView.play()
letanimationView=LOTAnimationView(name:"LottieLogo"bundle:yourBundle)self.view.addSubview(animationView)animationView.play()
letanimationView=LOTAnimationView(contentsOf:WebURL)self.view.addSubview(animationView)animationView.play()
lettranslation=gesture.getTranslationInView(self.view)letprogress=translation.y/self.view.bounds.size.height;animationView.animationProgress=progress
animationView.play(fromProgress:0.25,toProgress:0.5,withCompletion:nil)
<二> Controller 跳转动画 实现这个协议
<UIViewControllerTransitioningDelegate> , vc.transitioningDelegate = self;
这里的vcTransition1 是个.json的文件 , outLayer和inLayer 是这个文件里面的key#pragma mark -- View Controller Transitioning
- (id)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source { LOTAnimationTransitionController *animationController = [[LOTAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition1" fromLayerNamed:@"outLayer" toLayerNamed:@"inLayer" applyAnimationTransform:NO]; return animationController; }
- (id)animationControllerForDismissedController:(UIViewController *)dismissed { LOTAnimationTransitionController *animationController = [[LOTAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition2" fromLayerNamed:@"outLayer" toLayerNamed:@"inLayer" applyAnimationTransform:NO]; return animationController; }
outLayer和inLayer是文件里的, 制作时设置的
<三> 这个动画在运行过程中, 可以进行修改
修改底色
修改原色的颜色
地址 : http://airbnb.io/lottie/ios/dynamic.html建议先学学怎么做图 , 然后就用着熟了