Hello All,
Last week i have to do some animation in my application like zoom, rotate etc. I here share one of my trick to add object in view with some animation.
My goal is to remove view from its super view with rotating animation.
We will achieve that goal by using timer.We are using these two methods.
Last week i have to do some animation in my application like zoom, rotate etc. I here share one of my trick to add object in view with some animation.
My goal is to remove view from its super view with rotating animation.
We will achieve that goal by using timer.We are using these two methods.
- (void) removeWithSinkAnimation:(int)steps;
- (void) removeWithSinkAnimationRotateTimer:(NSTimer*) timer;
assuming that we have added our view to the screen and we want to remove it with animation.
- (void) removeWithSinkAnimation:(int)steps{
NSTimer *timer;
if (steps > 0 && steps < 100) // just to avoid too much steps
self.tag = steps;
else
self.tag = 50;
timer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(removeWithSinkAnimationRotateTimer:) userInfo:nil repeats:YES];
}
- (void) removeWithSinkAnimationRotateTimer:(NSTimer*) timer{
CGAffineTransform trans = CGAffineTransformRotate(CGAffineTransformScale(self.transform, 0.9, 0.9),0.314);
self.transform = trans;
self.alpha = self.alpha * 0.98;
self.tag = self.tag - 1;
if (self.tag <= 0)
{
[timer invalidate];
[view removeFromSuperview];
}
}
Thanks.
No comments:
Post a Comment