I want to create UIView Animation like this link
css3 ripple effect example
i have tried all these codes in ViewDidLoad() and not working
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 100, 100)];
view.backgroundColor = [UIColor blueColor];
CATransition *animation=[CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.75];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"rippleEffect"];
[animation setFillMode:kCAFillModeRemoved];
animation.endProgress=1;
[animation setRemovedOnCompletion:NO];
[view.layer addAnimation:animation forKey:nil];
[self.view addSubview:view];
i want to create the same thing in iOS .Please help me
The following lines of your code looks fine:
CATransition *animation=[CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.75];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"rippleEffect"];
[view.layer addAnimation:animation forKey:nil];
But, the problem is that your applying the animation before adding the view to its superview. which obviously will not work!
Try, to add the subview then apply the animation. I also expect that this will not work.
if you are adding this view to its superview in the viewDidLoad
method. apply the animation in the ViewDidAppear or ViewWillAppear methods.
Otherwise, create a separate method that applies the animation. and call it after you add the subview by calling performSelector:withObject:afterDelay
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With