在iOS 7中模式化具有翻转水平转换的视图控制器时,导航栏的位置错误

lu *_*uan 24 cocoa-touch uinavigationbar ios7

当我尝试在iOS7中模拟具有翻转水平过渡的视图控制器时,导航栏的原点在开始时为(0,0),然后在(0,20)处跳转到右侧位置.是否有可能使其在iOS6中表现相同?您可以在此处下载该项目.

我创建了一个自定义导航栏,如下所示:

@implementation MyCustomNavigationBar

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    UIImage *image = [UIImage imageNamed:@"Custom-Nav-Bar-BG.png"];


    [image drawInRect:CGRectMake(0,  0, self.frame.size.width, self.frame.size.height)];

    if (IOSVersion <7) {
    }else{
        self.translucent = NO;
        self.tintColor = [UIColor whiteColor];
        self.barStyle = UIBarStyleDefault;
        self.barTintColor = [UIColor redColor];

    }
}

@end
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

小智 57

我和你有同样的问题.我认为这是UIKit在iOS 7上的一个错误.

我在viewWillAppear方法上添加了一些代码

     [self.navigationController.navigationBar.layer removeAllAnimations];
Run Code Online (Sandbox Code Playgroud)

当我驳回这个观点时,我补充道:

-(IBAction)btnDonePressed:(id)sender {
    [UIView transitionWithView:self.navigationController.view
                      duration:0.75
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:nil
                    completion:nil];
    [self dismissViewControllerAnimated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

这对我有用.希望这对你有所帮助.

  • 这也适用于通过翻转动画呈现模态"UINavigationController"的segue.我在上面用`UIViewAnimationOptionTransitionFlipFromRight`选项添加了`UIView`转换来prepareForSegue,它修复了我的其余问题.我将为这个带有示例项目的雷达提交. (2认同)