开发者

how to create explode effect the UIView?

i need explode effect when the view change i.e., explode animation when i move to the next view. i found this type of animation in facebook app when 开发者_高级运维click the icon in the dash board

please help me


hai i finished the explode view this is my code thanks for your help

//Click event for view explode

  -(IBAction) buttonPressed: (id) sender{
    UIButton *buttonPressed = (UIButton *)sender;
   NSLog(@"buttonTag %d",buttonPressed.tag);
   @try {
    switch (buttonPressed.tag) {
            NSLog(@"Pugal");
        case 0:
            viewController=news;
            break;
        case 1:
            viewController=videoWeb;
            break;
        case 2:
            viewController=photo;
            break;
        case 3:
            viewController=events;  
            break;
        case 4:
            viewController=mobileWeb;
            break;

        default:
            break;

    }

}

[self performSelector:@selector(animateTransition:) withObject:[NSNumber numberWithFloat: TIME_FOR_EXPANDING]];
}

//animate Transition

-(void)animateTransition:(NSNumber *)duration {

self.view.userInteractionEnabled=NO;
[[self view] addSubview:viewController.view];
if ((viewController.view.hidden==false) && ([duration floatValue]==TIME_FOR_EXPANDING)) {
    viewController.view.frame=[[UIScreen mainScreen] bounds];
      viewController.view.transform=CGAffineTransformMakeScale(SCALED_DOWN_AMOUNT, SCALED_DOWN_AMOUNT);
}
viewController.view.hidden=false;
if ([duration floatValue]==TIME_FOR_SHRINKING) {
    [UIView beginAnimations:@"animationShrink" context:NULL];
    [UIView setAnimationDuration:[duration floatValue]];
    viewController.view.transform=CGAffineTransformMakeScale(SCALED_DOWN_AMOUNT, SCALED_DOWN_AMOUNT);
}
else {
        [UIView beginAnimations:@"animationExpand" context:NULL];

        [UIView setAnimationDuration:[duration floatValue]];
        viewController.view.transform=CGAffineTransformMakeScale(1, 1);
}
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
 }

//animated stop

   -(void)animationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context{

self.view.userInteractionEnabled=YES;

if ([animationID isEqualToString:@"animationExpand"]) {

    UINavigationController *navig = [[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];

    [self presentModalViewController:navig animated:NO];
}
else {
    viewController.view.hidden=true;
}
}

its work as per my require Thanks


On action...take a image View add it as subview to your view,load with series of images of explosion(or any thing which you want) start it animating, when the animation finishes from the delegate remove it from superview.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜