动画库 #import "Lottie/Lottie.h"
场景页面过渡效果
//给当前viewController设置代理<UIViewControllerTransitioningDelegate>
//实现页面压入和退出的动画函数 lottie动画类是实现<UIViewControllerAnimatedTransitioning>协议的所以直接返回一个自定义的动画类即可
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
LOTAnimationTransitionController *animationController = [[LOTAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition1" fromLayerNamed:@"outLayer" toLayerNamed:@"inLayer" applyAnimationTransform:NO];
return animationController;
}
//把新页面压入栈顶 然后调用动画函数
- (void)_showTransitionA {
ToAnimationViewController *vc = [[ToAnimationViewController alloc] init];
vc.transitioningDelegate = self;
[self presentViewController:vc animated:YES completion:NULL];
}
场景 普通动画使用
LOTAnimationView* lv = [LOTAnimationView animationNamed:@"LottieLogo1"];
lv.loopAnimation = YES;
lv.frame = CGRectMake(0, 0, 375, 600);
lv.animationSpeed = 1.2f;
[self.view addSubview:lv];
[lv play];
场景 开关 ❤️
LOTComposition *comp = [LOTComposition animationNamed:@"TwitterHeart"];
LOTAnimatedSwitch *toggle1 = [[LOTAnimatedSwitch alloc] initWithFrame:CGRectZero];
// 设置开启时的动画帧
[toggle1 setProgressRangeForOnState:0 toProgress:0.5];
// 设置关闭时的动画帧
[toggle1 setProgressRangeForOffState:0.5 toProgress:1];
[toggle1 setAnimationComp:comp];
toggle1.frame = CGRectMake(50, 200, 400,400);
[self.view addSubview:toggle1];
网友评论