iOS access Lottie

oc

With pod 

 

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

 

 

Loading animation

@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];

}

 

 

// Create a view of several methods + (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;
// available properties
@property(nonatomic,readonly)BOOLisAnimationPlaying;
// whether it is animation
@property(nonatomic,assign)BOOLloopAnimation;
// whether looping animation
@property(nonatomic,assign)CGFloatanimationProgress;
// animation execution progress
@property(nonatomic,assign)CGFloatanimationSpeed;
// animation speed
@property(nonatomic,readonly)CGFloatanimationDuration;
// animation time
// instance method
- (void)playWithCompletion:(LOTAnimationCompletionBlock)completion;
After // animation can execute a block
- (void) play; // Play
- (void) pause; // Pause
- (void)addSubview:(LOTView *)view toLayerNamed:(NSString *)layer;
 
Transition animation
 

<UIViewControllerTransitioningDelegate>代理

  HySecondViewController * v = [new HySecondViewController];

    

    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;

    

    

}



    

Guess you like

Origin www.cnblogs.com/hangman/p/11225003.html