如何在视图之间转换动画?

时间:2011-09-13 06:22:37

标签: iphone objective-c ios ios4

撰写新邮件时,iphone会使用动画(新视图来自屏幕底部)。我想将该动画添加到我的应用程序中。但我无法在预定义的过渡动画类型中找到它。 我怎么能加呢? 请帮我。

5 个答案:

答案 0 :(得分:6)

您可以切换到其他类似的UIViewControl:

[self presentModalViewController:yourUIViewController animated:YES];

有许多类型的动画,如...

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

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

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

答案 1 :(得分:0)

这就是你需要的:

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

在您的情况下,您需要指定此模态过渡样式,以使其来自底部:

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

答案 2 :(得分:0)

你不应该直接玩杂耍观点。顶级视图应关联视图控制器,控制器将为您执行转换(例如使用presentModalViewController:animated:方法)。

答案 3 :(得分:0)

这是您可以通过一些延迟动画在不同视图之间进行动画制作的方法。

- (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];
}

希望它对你有所帮助。

答案 4 :(得分:-1)

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


        }

       - (void) buttonTouch 

这个方法被称为它将呈现myView,它将从Facebook的底部到顶部滑动,如Mail Composer或Message Composer Effect。

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

        -(void) dismissmyView 

此方法在调用时将解除或取消当前的ModalView
              即myView