Luk*_*cka 6 cocoa-touch uinavigationbar uinavigationcontroller ios7
有没有什么办法有不同barTintColor的UINavigationController的UINavigationBar不同的推控制器与平滑的色彩过渡动画?
我希望UINavigationBar在UINavigationController推/动画动画期间有一个平滑的色彩动画,理想情况下也是交互式弹出(基于手势的控制器弹出).
我为什么需要这个?我想让导航堆栈中的1个控制器具有不同的色调颜色,指示某个任务的状态(红色/绿色等).
到目前为止我尝试了什么:
viewWillAppear(查看生命周期)方法,但没有办法动画barTintColor(像setBarTintColor:animated:)barTintColor在[UIView animation...]块中,但只是古怪动画(可能)的一些背景层,而不是平滑的颜色过渡的帧.barTintColor在[UIView transitionWithView:...]与块UIViewAnimationOptionTransitionCrossDissolve,但这并不改变动画.在动画持续时间后立即更改为新的色调颜色感谢大家的任何想法和答案
小智 26
你可以通过使用来获得这个UIViewControllerTransitionCoordinator.
AController并自定义颜色.BController并自定义颜色.UINavigationController推动/弹出过渡期间,它AController的风格将顺畅淡入/淡出BController风格.示例代码:
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[self transitionCoordinator] animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
// text color
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
// navigation items and bar button items color
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
// background color
self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
} completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2468 次 |
| 最近记录: |