在 iOS 7 中模态具有翻转水平过渡的视图控制器时,导航栏的位置错误 [英] Navigation bar has wrong position when modal a view controller with flip horizontal transition in iOS 7

查看:23
本文介绍了在 iOS 7 中模态具有翻转水平过渡的视图控制器时,导航栏的位置错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I am trying to modal a view controller with flip horizontal transition in iOS7, the origin of navigation bar is (0, 0) at beginning and then jump to the right position at (0, 20). Is it possible to make it behave the same with in iOS6? You can download the project here.

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

I have created a customized navigation bar as following:

@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

任何帮助将不胜感激.

推荐答案

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

I have the same problem with you. I think It's a bug with UIKit on iOS 7.

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

I added a little of code at viewWillAppear method on presentation

     [self.navigationController.navigationBar.layer removeAllAnimations];

当我关闭这个观点时,我补充说:

When I dismiss this view, I added:

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

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

This worked for me. Hope this helps you.

这篇关于在 iOS 7 中模态具有翻转水平过渡的视图控制器时,导航栏的位置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆