用于. CATransaction
_animation
注意:下面的代码depends
使用in 。UIInterfaceOrientation
Presenting a view
sliding down animation
all orienation
[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];
编辑:在这些方法中设置current
orientation
.So 添加UIInterfaceOrientation viewOrientation;
到 .h 文件中。这些方法可能会根据iOS version
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
viewOrientation = interfaceOrientation;
return YES; //return according to your requirement
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
viewOrientation = toInterfaceOrientation;
}