0

我一直在寻找一段时间,但我想要的基本上是“presentModalViewController”动画,但另一种方式......我希望屏幕顶部下降到底部以显示页面。有谁知道这叫什么?

这是我到目前为止的代码,但它发生得太快了......我该如何减慢它的速度?

-(void)gotToCreateGameViewController{
CreateNewGameViewController *newGame = [[CreateNewGameViewController alloc]initWithNibName:@"CreateNewGameViewController" bundle:nil];
self.createNewGameViewController = newGame;
createNewGameViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self presentModalViewController:newGame animated:YES];
[self.view insertSubview:newGame.view atIndex:0];

[newGame release];
4

3 回答 3

2

我认为您正在寻找: UIModalTransitionStyleCoverVertical

Presentation Transition Styles
Transition styles available when presenting view controllers.

typedef enum {
        UIModalTransitionStyleCoverVertical = 0,
        UIModalTransitionStyleFlipHorizontal,
        UIModalTransitionStyleCrossDissolve,
        UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;

它从下到上呈现,然后在关闭时从上到下。要从上到下转换,您需要自己滚动,或者从下面的目标 vc 开始,并以模态方式显示起始 vc。

于 2012-04-24T17:38:35.307 回答
1

试试这个代码

  -(void)gotToCreateGameViewController{
        CreateNewGameViewController *newGame = [[CreateNewGameViewController alloc]initWithNibName:@"CreateNewGameViewController" bundle:nil];
        self.createNewGameViewController = newGame;

        CATransition *transition = [CATransition animation];
        transition.duration = 0.05;
        transition.timingFunction = [CAMediaTimingFunction      
        functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type =kCATransitionMoveIn;
        CATransition *transition = [CATransition animation];
        transition.duration = 0.05;
        transition.timingFunction = [CAMediaTimingFunction      
        functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type =kCATransitionMoveIn;
        transition.subtype =kCATransitionFromTop;

        transition.delegate   = self;

        transition.subtype =kCATransitionFromTop;

        transition.delegate = self;


        [self presentModalViewController:newGame animated:NO];
        [self.view insertSubview:newGame.view atIndex:0];

        [self.view.layer addAnimation:transition forKey:nil]; 

        [newGame release];

请注意,UIModalTransitionStyle 仅适用于 iPad 应用程序。请参阅文档。

于 2012-04-24T18:18:34.040 回答
0

我的骇人听闻的回答:

如果您将初始视图向下移动到 y = 960(您可能必须添加另一个视图,然后将所有内容剪切并粘贴到该视图中),并将您的第二个视图放置在 y = 0,您可以实现以下代码。实例化一个 BOOL 后(我叫 mine movedUp):

-(void)moveView:(float)d{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:d];  

    CGRect rect = self.view.frame;
    if (!movedUp)
    {
        rect.origin.y -= 960;
        rect.size.height += 960;
    }
    else
    {
        // revert back to the normal state.
        rect.origin.y += 960;
        rect.size.height -= 960;
    }
    self.view.frame = rect;

    [UIView commitAnimations];
    movedUp = !movedUp;
}
- (void)viewDidAppear:(BOOL)animated
{
    [self moveView:0.0];
    [super viewDidAppear:animated];
}

然后我将两个按钮(每个视图中一个)连接到以下:

-(IBAction)setViewMovedUp:(id)sender
{
    [self moveView:0.5];
}
于 2012-04-24T19:50:13.150 回答