lottie-ios学习笔记

地址:https://github.com/airbnb/lottie-ios
很多简友说这个没有OC版本的了都是swift版本,
我暂时传了一个 OC以前版本到自己的Git仓库
pod 刚刚上传了 可以用下面的进行安装 如果搜索不到请更新pod 库

   pod 'lottie-ios_Oc'

oc版本
素材下载地址:https://www.lottiefiles.com/
下载下来是 json 文件
oc 语言使用 pod 安装
pod 'lottie-ios'
pod install 命令 完成后
导入头文件

#import 
    LOTAnimationView *animation = [LOTAnimationView animationNamed:@"ripple"];
    animation.backgroundColor = [UIColor redColor];
    animation.frame = CGRectMake(0, 100, 300, 300);
    [self.view addSubview:animation];

//执行动画有两种方式 
#mark 第一种 全部执行完
[animation playWithCompletion:^(BOOL animationFinished) {
  // Do Something
}];
# mark 也可以直接设置动画进度
animation.animationProgress = progress;
# mark 还可以使用 
[animation playFromProgress:0.25 toProgress:0.5 withCompletion:^(BOOL animationFinished) {
  // Do Something
}];

# mark 从官方摘抄代码
// ===========  还可以自定义present 动画  ======= 

 ToAnimationViewController *vc = [[ToAnimationViewController alloc] init];
  vc.transitioningDelegate = self;
  [self presentViewController:vc animated:YES completion:NULL];
#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;
}

你可能感兴趣的:(lottie-ios学习笔记)