我怎么能在动画的UIViewController推UINavigationBar的背景变化? [英] how can I animate the UINavigationBar background change on UIViewController push?
问题描述
我的应用程序使用两个不同背景的UINavigationBar的以指示他们在什么样的水平层次结构中的用户。当我推需要它缺少动画第二背景一个UIViewController,背景立即只要UIViewController中被推变化。我怎样才能动画这个使背景的变化渐渐消失看法正在发生变化?
My app uses two different backgrounds for the UINavigationBar to indicate to the user what level in the hierarchy they're at. When I push a UIViewController that needs the second background it lacks animation, the background changes immediately as soon as the UIViewController is pushed. How can I animate this so that the background change fades as the view is being changed?
推荐答案
我知道这是一个古老的线程,但这个工作对我来说:
I know this is an old thread, but this worked for me:
CATransition *transition = [CATransition animation];
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
transition.type = kCATransitionFade;
transition.duration = 0.5;
[self.navigationController.navigationBar.layer addAnimation:transition forKey:nil];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage imageNamed:@"navigationbar.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(44, 20, 44, 20)] forBarMetrics:UIBarMetricsDefault];
把这个你的 viewDidLoad中
方法内。你需要链接/导入 QuartzCore 框架。
Place this inside your viewDidLoad
method. You'll need to link/import the QuartzCore framework.
这篇关于我怎么能在动画的UIViewController推UINavigationBar的背景变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!