iOS 7上的UINavigationBar闪烁问题

3
每当我的应用程序启动时(仅在iPad上),导航栏会短暂地闪白色,然后弹出其条形色。您可以在此处查看动画GIF:enter image description here 我正在设置一个UINavigationController子类的色调,在iPhone上这个配置完美运行。
//This returns a UIColor
self.navigationBar.barTintColor = [[IGVThemeManager sharedManager] themeColor];

self.navigationBar.tintColor = [UIColor whiteColor];
self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Light" size:20]};

我也尝试过移除子类并通过界面构建器手动设置bar tint颜色,但仍然出现相同的“闪烁”结果。有什么其他可能导致这种情况的想法吗?这种情况发生在模拟器和设备上。注意:如果需要任何想法,此导航控制器作为分割视图控制器的一部分存在。


我已经制作了大量的通用应用程序,并为UINavigation栏设置了自定义色调和颜色,它们从未表现出您所看到的那种行为。我不知道IGVThemeManager是什么?它可能与代码有关吗? - Sam B
嘿@SamBudda,谢谢回复,我也从未遇到过这种情况...这是与IGVThemeManager相关的所有代码:https://gist.github.com/jaysonlane/4f11ae60048ebc0d7176,我也尝试了将其作为静态UIColor使用,但结果相同。 - Jayson Lane
3个回答

0

可能有点晚了 - 我遇到了同样的问题,但是无法找出原因。我正在调用:

  if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;

我之前需要这个东西用于另一个视图的模板,不小心把它留在了那里。移除这个调用就解决了问题。


0

删除您当前拥有的代码,尝试将以下代码添加到您的appdeletgate.m文件中。如果它仍然闪烁,则可能存在其他问题。

注意:为了给我的导航栏着色,我添加了一张蓝色图片。文本颜色为白色。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

UIImage *NavigationPortraitBackground = [UIImage imageNamed:@"blue_color_header_pic"];

// Set the background image all UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:NavigationPortraitBackground forBarMetrics:UIBarMetricsDefault];



// Set the text appearance for navbar
[[UINavigationBar appearance] setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIColor whiteColor], UITextAttributeTextColor,
  [UIColor whiteColor], UITextAttributeTextShadowColor,
  [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
  [UIFont fontWithName:@"Helvetica Neue" size:21], UITextAttributeFont,
  nil]];


NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                            [UIColor whiteColor],
                            UITextAttributeTextColor,
                            [UIColor whiteColor],
                            UITextAttributeTextShadowColor, nil];

[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState: UIControlStateNormal];


// Override point for customization after application launch.
return YES;
}

0
将您的代码移动到: < p > < code > - (void)viewDidLayoutSubviews 这样就可以了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接