Reputation: 101
I want to create UIView Animation like this link
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
Upvotes: 7
Views: 4847
Reputation: 24205
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.
Upvotes: 4
Reputation: 3811
Hope this helps you Sample class
UIView+Glow is a category on UIView that adds support for making views glow (useful for highlighting a part of the screen to encourage the user to interact with it).
To learn what it can be used for, and how to use it, check out the blog post
Upvotes: 0