美文网首页
Lottie动画相关

Lottie动画相关

作者: Vijay_ | 来源:发表于2017-10-08 12:21 被阅读9次

动画库 #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];

相关文章

网友评论

      本文标题:Lottie动画相关

      本文链接:https://www.haomeiwen.com/subject/ozyeyxtx.html