通过我的应用程序,我有不同颜色的导航栏。 此外,我有一些图表以横向显示,而我的应用程序的其余部分以纵向显示。 在某些观点中,我隐藏了标签栏。
我更改了viewDidLoad和viewWillAppear中的导航栏颜色。
我的问题是视图之间的过渡效果看起来很奇怪。 如果导航栏的颜色不同,则颜色变化太快,第一个屏幕会发生变化。或者您可以看到要删除的标签栏。
我做错了什么?
以下是我使用的一些典型代码。
CBViewController *nextController = [[CBViewController alloc]
initWithNibName:@"CBView" bundle:nil];
nextController.title = @"CB";
nextController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextController animated:YES];
我不是在寻找没有标准效果的东西,而是看起来不奇怪的东西。
虽然,我看到了滑动效果,从第一个视图到第二个看起来很好。
答案 0 :(得分:-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];
}
}