我正在使用 UIViewAnimationOptionTransitionCrossDisolve 从一个视图转换到另一个视图。
我遇到的问题是,在过渡生效后,我的屏幕顶部有 20 个像素的间隙,并且新的 UIViewController 向上推,因此屏幕看起来很正常。
我该如何解决?
这是我的转换代码:
- (IBAction)logInButtonTapped
{
[self performTransition:UIViewAnimationOptionTransitionCrossDissolve];
}
-(void)performTransition:(UIViewAnimationOptions)options
{
//Step 1: Create your Controllers
_frontViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
NSLog(@"ViewController Frame: %@", NSStringFromCGRect(_frontViewController.view.frame));
_frontViewController.wantsFullScreenLayout = NO;
self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);
UIViewController * leftViewController = [[LeftSideViewController alloc] init];
//Step 2: Instantiate your PKRevealController
self.revealController = [PKRevealController revealControllerWithFrontViewController:_frontViewController leftViewController:leftViewController rightViewController:nil options:nil];
UIView * fromView, *toView;
if ([self.view superview] != nil)
{
fromView = self.view;
toView = self.revealController.view;
NSLog(@"After Transition ViewController Frame: %@", NSStringFromCGRect(_frontViewController.view.frame));
}
[UIView transitionFromView:fromView toView:toView duration:0.5
options:options completion:^(BOOL finished){}];
}
这是我的 NSLog 显示的内容:
2013-04-03 18:14:30.560 AppName[24631:c07] {{0, 0}, {320, 548}}
2013-04-03 18:14:31.691 AppName[24631:c07] ViewController Frame: {{0, 0}, {320, 568}}
2013-04-03 18:14:31.692 AppName[24631:c07] After Transition ViewController Frame: {{0, 0}, {320, 548}}