zoukankan      html  css  js  c++  java
  • iOS接入 Lottie

    oc

    用pod 

     pod 'lottie-ios', '~> 2.5.2'

    加载动画

    @property (nonatomic, strong) LOTAnimationView * lottielogo;

    self.lottielogo = [LOTAnimationView animationNamed:@"LottieLogo1"];

        

        self.lottielogo.contentMode = UIViewContentModeScaleAspectFill;

        

        self.lottielogo.frame  = CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height*1/3);

        

        [self.view addSubview:self.lottielogo];

    -(void)viewWillAppear:(BOOL)animated{

        

        [super viewWillAppear:animated];

        

        [self.lottielogo play];

    }

    -(void)viewDidDisappear:(BOOL)animated{

        

        [super viewDidDisappear:animated];

        

        [self.lottielogo pause];

    }

    //创建视图的几个方法 + (instancetype)animationNamed:(NSString *)animationName NS_SWIFT_NAME(init(name:));
    + (instancetype)animationNamed:(NSString *)animationName inBundle:(NSBundle *)bundle NS_SWIFT_NAME(init(name:bundle:));
    + (instancetype)animationFromJSON:(NSDictionary *)animationJSON NS_SWIFT_NAME(init(json:));
    - (instancetype)initWithContentsOfURL:(NSURL *)url;
    //可用属性
    @property(nonatomic,readonly)BOOLisAnimationPlaying;
    //是否正在动画
    @property(nonatomic,assign)BOOLloopAnimation;
    //是否循环播放动画
    @property(nonatomic,assign)CGFloatanimationProgress;
    //动画执行进度
    @property(nonatomic,assign)CGFloatanimationSpeed;
    //动画速度
    @property(nonatomic,readonly)CGFloatanimationDuration;
    //动画时间
    //实例方法
    - (void)playWithCompletion:(LOTAnimationCompletionBlock)completion;
    //动画结束后可以执行一个block
    - (void)play;  //播放
    - (void)pause; //暂停
    - (void)addSubview:(LOTView *)view toLayerNamed:(NSString *)layer;
     
    转场动画
     

    <UIViewControllerTransitioningDelegate>代理

      HySecondViewController * vc = [HySecondViewController new];

        

        vc.transitioningDelegate = self;

        

        [self presentViewController:vc animated:YES completion:nil];

        

    #pragma mark == View ControllerView dele ==

    -(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;

        

    }

    -(id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{

        

        LOTAnimationTransitionController *animationController = [[LOTAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition2"

                                                                                                                  fromLayerNamed:@"outLayer"

                                                                                                                    toLayerNamed:@"inLayer"

                                                                                                         applyAnimationTransform:NO];

        return animationController;

        

        

    }



        

    一天一章
  • 相关阅读:
    vue从详情页回到列表页,停留在之前的tab上
    vue-touch监听手指左滑右滑事件
    vue事件代理
    vue通过ref获取组件渲染后的dom(this.$refs.xxxRef.$el)
    vue水印-第二种方法:通过指令
    # 有时候代码超时
    # 今天的leetcode1268又用上了二分搜索。
    # linux命令小常识
    # 大家好
    今天尝试配置maven的时候
  • 原文地址:https://www.cnblogs.com/hangman/p/11225003.html
Copyright © 2011-2022 走看看