转换UINavigationBar颜色? [英] Transitioning UINavigationBar colors?

查看:143
本文介绍了转换UINavigationBar颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上试图在iPhone上复制iPod应用程序的行为,当您选择歌曲时,音乐播放器视图会滑入,导航栏将转换为新颜色。

I'm basically trying to duplicate the behavior of the iPod app on the iPhone, where when you select a song, the music player view slides in, and the navigation bar transitions to a new color.

我的应用程序设置为基于选项卡的应用程序,使用UITabBarController和每个选项卡中的嵌套UINavigationController。在每个UINavigationController的每个选项卡内是一个UITableView。当我在表中选择一个项目时,我使用pushViewController滑动到下一个视图,我已经在下一个视图控制器中设置hidesBottomBarWhenPushed,以滑动标签。该行为非常接近iPod正在播放页面,这是接近完美。

My app is set up as a tabbed based application, with UITabBarController and a nested UINavigationController in each tab. Inside each UINavigationController for each tab is a UITableView. When I select an item in the table, I'm using pushViewController to slide to the next view, and I've set hidesBottomBarWhenPushed in the next view controller in order to slide the tabs away. The behavior is very close to the iPod "Now Playing" page, which is nearly perfect.

最后的问题是,我无法转换导航的颜色吧,就像iPod应用程序中的导航栏从蓝色变为黑色一样。我可以在新视图出现后强制更改颜色(在viewWillAppear中),但是更改是突然的,并且不会模仿iPod应用程序的行为,并具有淡入效果。

The final problem is that I'm unable to transition the color of the navigation bar, like how the navigation bar in the iPod app fades from blue to black. I'm able to force the color change after the new view appears (in viewWillAppear), but the change is abrupt and does not mimic the behavior of the iPod app, with a fade effect.

有没有人知道我在这里失踪?它似乎是一个非常简单和常见的UI,我在几个应用程序中看到,但似乎没有明显的方法来做。

Does anyone know what I'm missing here? It seems like a very simple and common UI that I've seen in several applications, but there doesn't appear to be an obvious way to do it.

推荐答案

您可以对状态栏样式更改进行动画处理,以创建非常接近的效果。

You can animate the status bar style change to create an effect that's pretty close.

- (void)viewWillAppear:(BOOL)animated {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:animated];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
}

您注意到导航栏样式会立即更改,到状态栏仍然提供转换的整体外观。

As you've noticed the navigation bar style changes immediately, but the animated change to the status bar still provides the overall appearance of a transition.

这篇关于转换UINavigationBar颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆