24

当我尝试在 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

任何帮助将不胜感激。

4

3 回答 3

57

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

我在演示文稿的 viewWillAppear 方法中添加了一些代码

     [self.navigationController.navigationBar.layer removeAllAnimations];

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

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

这对我有用。希望这对您有所帮助。

于 2013-10-09T07:20:11.573 回答
4

而不是 hacking [navigationBar.layer removeAllAnimations];,这样的东西也应该起作用:

[UIView transitionWithView:self.view.window duration:FlipDuration options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
    [UIView performWithoutAnimation:^{
        [self presentViewController:modalController animated:NO completion:nil];
    }];
} completion:nil];
于 2014-05-05T08:38:50.523 回答
3

只需在选项“ios 6/7 Deltas”的 xib 中给出 -20

或阅读此

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/index.html#//apple_ref/doc/uid/TP40006556-CH66-SW1

于 2013-10-03T07:19:40.870 回答