Iphone 查看过渡动画

Iphone 查看过渡动画,iphone,ios,objective-c,xcode,cocoa-touch,Iphone,Ios,Objective C,Xcode,Cocoa Touch,当你打电话时: [self dismissViewControllerAnimated:Yes.....]; 它与用于显示视图的任何动画相反 例:如果你打电话: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil]; View * myView = (View *) [storyboard instantiateViewControllerWithIdentifier:@"my

当你打电话时:

[self dismissViewControllerAnimated:Yes.....];
它与用于显示视图的任何动画相反

例:如果你打电话:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
View * myView = (View *) [storyboard instantiateViewControllerWithIdentifier:@"myViewName"];
[self myView animated:YES completion:nil];
它从底部向上移动视图,并且
dismissViewControllerAnimated:
将使用反向动画关闭视图,因此视图将向下滑动


是否有任何方法可以
显示带有向下滑动动画的视图?非常感谢您的帮助

对于
动画
使用
CATTransaction

注意:下面的代码
取决于
UIInterfaceOrientation
所有方向中的
向下滑动动画
呈现视图

[CATransaction begin];
CATransition *transition;
transition = [CATransition animation];
transition.type = kCATransitionPush;
if(viewOrientation == UIInterfaceOrientationLandscapeLeft)
    [transition setSubtype:kCATransitionFromLeft];
else if (viewOrientation == UIInterfaceOrientationLandscapeRight)
    [transition setSubtype:kCATransitionFromRight];
else if (viewOrientation == UIInterfaceOrientationPortrait)
    [transition setSubtype:kCATransitionFromLeft];
else 
    [transition setSubtype:kCATransitionFromRight];

transition.duration = 0.0;
[self.view.layer addAnimation:transition forKey:nil]; // add animation in layer of UIView.
//Present your View here
[CATransaction commit];
编辑:在这些方法中设置
当前
方向
。因此添加
UIInterfaceOrientation视图方向在.h文件中。这些方法可能会根据iOS版本的不同而变化

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   viewOrientation = interfaceOrientation;
   return YES; //return according to your requirement
}

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
  viewOrientation = toInterfaceOrientation;
}

当然,您可以这样做自己的转换:

 -(IBAction)presentNext:(id)sender {

    UIViewController *next = [self.storyboard instantiateViewControllerWithIdentifier:@"Next"];
    [self.view.window insertSubview:next.view belowSubview:self.view];
    CGAffineTransform t;
    __block NSInteger xOffset, yOffset;
    switch (self.interfaceOrientation) {
        case 1:
            xOffset = 0;
            yOffset = self.view.frame.size.height;
            break;
        case 3:
            t = CGAffineTransformMakeRotation(90 * M_PI / 180);
            next.view.transform = t;
            xOffset = -self.view.frame.size.width;
            yOffset = 0;
            break;
        case 4:
            t = CGAffineTransformMakeRotation(-90 * M_PI / 180);
            next.view.transform = t;
            xOffset = self.view.frame.size.width;
            yOffset = 0;
            break;
        default:
            break;
    }

    next.view.frame = self.view.frame;
    [UIView animateWithDuration:1 animations:^{
        self.view.center = CGPointMake(self.view.center.x + xOffset, self.view.center.y + yOffset);
    } completion:^(BOOL finished) {
        [self presentViewController:next animated:NO completion:^{
            [self.view removeFromSuperview];
        }];
    }];
}

您想要显示/显示带有动画的ViewController,如
解除ViewController激活的
?@iPatel是的,先生,我当然想要。我这样做的原因很复杂。