0

在我的应用程序中,我有不同颜色的导航栏。此外,我有一些以横向显示的图表,而我的应用程序的其余部分以纵向显示。在某些视图中,我隐藏了我的标签栏。

我在 viewDidLoad 和 viewWillAppear 中更改导航栏颜色。

我的问题是视图之间的过渡效果看起来很奇怪。在导航栏有不同颜色的地方,颜色变化太快,第一个屏幕发生变化。或者您可以看到标签栏被删除。

我究竟做错了什么 ?

这是我使用的一些典型代码。

CBViewController *nextController = [[CBViewController alloc] 
      initWithNibName:@"CBView" bundle:nil];
nextController.title = @"CB";   
nextController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextController animated:YES];

我不是在寻找没有标准的效果,而是看起来并不奇怪的东西。

虽然,我已经看到了滑动效果,从第一个视图到第二个看起来不错。

4

1 回答 1

-1

在您发表评论后,我仍然不确定您在寻找什么——我的 iTunes 中没有看到任何导航栏颜色变化(他们经常更新 iTunes,也许我们正在查看不同的版本)。无论如何,以下代码将导致导航栏在转换到新控制器时改变颜色。由于推送动画只有大约 0.3 秒,并且 NSTimer 被限制在大约 0.05 秒的分辨率,我做了六个步骤来从一种颜色到另一种颜色(从绿色到黄色)。

-(IBAction)pushWithColorChange:(id)sender {
    UIViewController *nextController = [self.storyboard instantiateViewControllerWithIdentifier:@"Yellow"];
    [self.navigationController pushViewController:nextController animated:YES];
    [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(changeColor:) userInfo:nil repeats:YES];
}

-(void)changeColor:(NSTimer *) timer {
    static float i=0.03;
    self.navigationController.navigationBar.tintColor = [UIColor colorWithHue:.34 - i saturation:.5 brightness:.7 alpha:1];
    i += 0.03;
    if (i > .18) {
        [timer invalidate];
    }
}
于 2012-12-30T17:05:45.083 回答