Reputation:
I am trying animate and get transferred only when the animation gets finished..but everything works fine except the segue...when I clicked the button it navigates to another page...before the animation gets finished... I a new bee to ios please mention my mistake...
#import "ViewController.h"
#import <Lottie/lottie.h>
@interface ViewController ()
@property UIView * AnimatedViewForLoading;
@property LOTAnimationView * LottieAnimationHourGlass;
@end
-(IBAction)ButtonTouched:(id)sender {
self.AnimatedViewForLoading = [[UIView alloc] initWithFrame:CGRectMake(118, 318, 200, 150)];
[self.AnimatedViewForLoading setBackgroundColor:[UIColor clearColor]];
// self.AnimatedViewForLoading.alpha = 0.0f;
//AnimatedViewForLoading.backgroundColor = UIColor.lightGrayColor;
self.LottieAnimationHourGlass = [LOTAnimationView animationNamed:@"hourglass"];
self.LottieAnimationHourGlass.frame = CGRectMake(118, 318, 200, 150);
// if(!UIAccessibilityIsReduceTransparencyEnabled()){
// self.view.backgroundColor = [UIColor clearColor];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *blureffectview = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
blureffectview.frame = self.view.bounds;
blureffectview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:blureffectview];
[self.view insertSubview:_AnimatedViewForLoading aboveSubview:blureffectview];
//[self.view sendSubviewToBack:_AnimatedViewForLoading];
[self.view insertSubview:_LottieAnimationHourGlass aboveSubview:_AnimatedViewForLoading];
[_LottieAnimationHourGlass play];
_LottieAnimationHourGlass.loopAnimation = YES;
// }else{
//self.view.backgroundColor = [UIColor blackColor];
// }
self.AnimatedViewForLoading.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:10.0 delay:3.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.AnimatedViewForLoading.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
NSLog(@"oopssssss..........");
[UIView animateWithDuration:0.3/2 animations:^{
self.AnimatedViewForLoading.transform = CGAffineTransformIdentity;
}];
if (finished == true) {
[self dismissViewControllerAnimated:YES completion:nil];
[self performSegueWithIdentifier:@"YourTimeisLoading" sender:_AnimatedViewForLoading];
}
}];
//[self dismissViewControllerAnimated:YES completion:nil];
}
Upvotes: 1
Views: 108
Reputation: 82759
scenario 1:
check your second completion
[UIView animateWithDuration:10.0 delay:3.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.AnimatedViewForLoading.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
NSLog(@"oopssssss..........");
[UIView animateWithDuration:0.3/2 animations:^{
self.AnimatedViewForLoading.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) {
[self dismissViewControllerAnimated:YES completion:nil];
[self performSegueWithIdentifier:@"YourTimeisLoading" sender:_AnimatedViewForLoading];
}];
}];
scenario 2:
ensure once your performSegueWithIdentifier
is connected with VC not directed in button.If its directly connected with your UIButton,it won't consider anything inside the action handler.
Upvotes: 1