0

如果可以将导航控制器动画更改为某种东西,而不是新视图只是滑到视图上,我会很高兴,因为新视图滑动时,当前视图会滑落......

我在这里有这个功能,它只是检测我的滑动,然后像普通的导航控制器一样为视图设置动画......但我希望我能在你的帮助下解决其他问题。

// Need to change this to work with viewArray
- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture {

    //Left swipe
    if (gesture.direction == UISwipeGestureRecognizerDirectionLeft) 
    {
        if (viewCount == 0) 
        {     
            viewCount += 1;
            // Load a detial view into the (sub)NavController
            DetailViewControllerA *detailViewA = [[DetailViewControllerA alloc] initWithNibName:@"DetailViewControllerA" bundle:[NSBundle mainBundle]];
            [otherNav pushViewController:detailViewA animated:YES];
        }
    }
    //Right swipe
    else if (gesture.direction == UISwipeGestureRecognizerDirectionRight)
    {
        if (viewCount == 1) 
        {
            viewCount -= 1;
            [self.otherNav popViewControllerAnimated:YES]; 
        }
    }  
}
4

1 回答 1

1

您可以使用 uiView 动画块来做到这一点,就像我用来显示一个闪烁的 UIView

[UIView animateWithDuration:1.0 
                          delay:0.0 
                        options:UIViewAnimationCurveEaseInOut 
                     animations:^ {
                         self.splash.alpha = 0.2;
                     } 
                     completion:^(BOOL finished) {
                         [UIView animateWithDuration:1.0 animations:^{
                             self.splash.alpha = 1.0;
                         }];
                     }];

或者

使用下面的代码

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.window cache:YES];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationDelegate:self];
    [self.splash removeFromSuperview];
    [UIView commitAnimations];

用于翻转过渡

为了改变推送/弹出动画,我使用了这段代码

    [UIView  beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [self.navigationController pushViewController:self.detailViewController animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];

享受编码:)

快乐编码:)

于 2012-06-01T09:38:22.173 回答