iphone - ios7 UINavigationBar 一段时间后停止在状态栏下延伸

标签 iphone ios7 uinavigationcontroller uinavigationbar statusbar

首先 - 这不是关于导航栏重叠状态栏的问题(与许多其他问题一样)。 UINavigationBar(我的导航 Controller )完全按照我的要求对齐。

问题出在我的导航栏自定义背景上。
背景图像(或导航栏本身)在状态栏下随机停止扩展(在我的应用程序启动几秒钟后或当我在其上呈现/关闭模态导航 Controller 时)。 我的自定义图像具有适合 iOS 的尺寸 (640x128px)。

<强>1。初始外观(所需 - 自定义 640x128px 背景在状态栏下很好地延伸):

enter image description here

<强>2。过了一会儿(自行闪烁):

enter image description here

什么可能导致 UINavigationBar 背景图像随机闪烁?

我使用以下代码来配置我的背景:

    // Load resources for iOS 7 or later
    [[CustomNavigationBar appearance] setBackgroundImage:[self imageNamed:@"bg_top_ios7.png"] forBarMetrics:UIBarMetricsDefault];
    [[CustomNavigationBar appearance] setBackgroundImage:[self imageNamed:@"bg_top_ios7.png"] forBarMetrics:UIBarMetricsDefaultPrompt];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];

Info.plist 文件中我的状态栏设置:

enter image description here

我的 UIViewController 子类 init 方法中还有以下设置(不确定是否重要):

-(id)init{
//DLog(@"BaseViewController init...");
    if (self = [super init]) {

        popToRoot = modal = NO;
        rootIndex = 0;
        indexInBottomNavigation = 0;
        [Crashlytics setObjectValue:@"init" forKey:NSStringFromClass([self class])];


        // iOS 7 adoptions:
        if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
            self.edgesForExtendedLayout = UIRectEdgeNone;

        if ([self respondsToSelector:@selector(extendedLayoutIncludesOpaqueBars)])
            self.extendedLayoutIncludesOpaqueBars = YES;

        if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)])
            self.automaticallyAdjustsScrollViewInsets = NO;


    }
    return self;
}

我的 View Controller 嵌入在 UINavigationController 中(它负责 UINavigatioBbar 定位)。 我还使用 ECSlidingViewController (显示容器)作为导航 Controller 的容器,但我不确定这是否重要。

最佳答案

事实证明,我正在更改导航 Controller 导航栏(应用程序中的某个位置)的 clipsToBounds = YES:

navigationController.navigationBar.clipsToBounds = YES;

为了让UINavigationBar在状态栏下扩展其背景 其clipsToBounds必须设置为NO(这是默认值)。 确保你没有用它来 mock 。

解决方案简单如下:

navigationController.navigationBar.clipsToBounds = NO;

关于iphone - ios7 UINavigationBar 一段时间后停止在状态栏下延伸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20991861/

相关文章:

ios - 如何从 XMPP 库 ios 中获取所有注册用户?我试过这个但得到错误代码 404,找不到项目

iphone - 将 firemonkey 应用提交到应用商店的问题

ios - 将大对象从 ViewController 发送到 Objective C 中的另一个,ios?

iOS 以编程方式转到选项卡和推送 View Controller

ios - 从侧面菜单中选择项目时打开特定的 ViewController?

ios - 使用导航 Controller 时保留标题 View

iphone - Apple 目前不接受使用此版本 SDK 构建的应用程序

iphone - 如何查看应用程序中调用方法和函数的顺序?

ios - MKPolylineRenderer 产生锯齿状、不相等的路径

ios - iOS7 有类似 UIAccessibilityCustomAction 的东西吗?