【问题标题】:ios7 UINavigationBar stops extending under status bar after a while一段时间后,ios7 UINavigationBar 在状态栏下停止扩展
【发布时间】:2014-01-26 07:54:59
【问题描述】:

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

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

1.初始外观(需要 - 自定义 640x128px 背景在状态栏下很好地延伸):

2。片刻之后(自行闪烁):

什么会导致 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 文件中我的状态栏设置:

我的 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;
}

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

【问题讨论】:

    标签: iphone ios7 uinavigationcontroller uinavigationbar statusbar


    【解决方案1】:

    原来我正在更改导航控制器导航栏的clipsToBounds = YES(在应用程序的某个位置):

    navigationController.navigationBar.clipsToBounds = YES;

    为了让UINavigationBar在状态栏下扩展它的背景 它的 clipsToBounds 必须设置为 NO(这是默认设置)。 确保你不要拿它开玩笑。

    解决方法简单如下:

    navigationController.navigationBar.clipsToBounds = NO;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-15
      • 1970-01-01
      • 2020-06-02
      相关资源
      最近更新 更多