开发者

how to animate transition between views?

when compose a开发者_JS百科 new message, iphone use an animation (new view comes from bottom of the screen). I want to add that animation to my application. But I can't find it in pre-define transition animation types. How could I add it?

Please give me help.


You can switch to other UIViewControllers like this:

[self presentModalViewController:yourUIViewController animated:YES];

There are many types of animation like...

yourUIViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:yourUIViewController animated:YES];

yourUIViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:yourUIViewController animated:YES];

yourUIViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:yourUIViewController animated:YES];


You should not juggle views directly. Top-level views should have a view controller associated, and the controller will do the transitions for you (like using the presentModalViewController:animated: method).


This is what you need:

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated;

In your case you need to specify this modal transition style in order to make it come from the bottom:

UIViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:yourUIViewController animated:YES];


This is how you can animate transition between different views with some delay.

- (void)viewsAction:(id)sender
{  

  First *first = [[First alloc] init];

  first.view.frame = CGRectMake(0, 0, 320, 425);

  CATransition *transitionAnimation = [CATransition animation];

  [transitionAnimation setDuration:1];

  [transitionAnimation setType:kCATransitionFade];

   [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];

   [first.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade];

     [self.view addSubview:first.view]; 

     [first release];

      self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Second) userInfo:nil repeats:NO];

   }

  -(void)Second 
 {
    Second *second = [[Second alloc] init];

second.view.frame = CGRectMake(0, 0, 320, 425);

CATransition *transitionAnimation = [CATransition animation];

[transitionAnimation setDuration:1];

[transitionAnimation setType:kCATransitionPush];

[transitionAnimation setSubtype:kCATransitionFromRight];

[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[second.view.layer addAnimation:transitionAnimation forKey:kCATransitionPush];

[self.view addSubview:second.view]; 

  [second release];

self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO];
}

Hope it helps you.


              - (void) buttonTouch
        {
        myView *Obj=[[myView alloc]init];
        [self presentModalViewController:Obj animated:YES];


        }

       - (void) buttonTouch 

This method is called it will present myView which will be sliding from bottom to top of screen like Mail Composer or Message Composer Effect.

            -(void) dismissmyView
             {
               [self dismissModalViewControllerAnimated:YES];
             }  

        -(void) dismissmyView 

This method when called it will dismiss or cancels the current ModalView
i.e. myView

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜