我试图从一个 VC 推送到另一个 - 这是 0 问题,但是 VC1 有一个橙色的 NavigationBar 而 VC2 有一个完全透明的 NavigationBar。我想在推送 segue 期间在 2 个不同的 NavigationBars 之间顺利过渡。然而,目前 - 它出现了这个黑色的滑动条,并且颜色没有很好地过渡。这是我的代码:
VC1 viewWillAppear:
// Set the BarTintColor to translucent and text colors to white
[UIView animateWithDuration:0.5 animations:^{
self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
}];
VC 2 viewWillAppear:
// Make the NavigationBar transparent
[UIView animateWithDuration:0.5 animations:^{
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
}];
我怎样才能以更有效和更好的方式解决这个问题?
谢谢! 埃里克
最佳答案
这样解决:
// Make the NavigationBar transparent
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
[UIView animateWithDuration:0.4 delay:0 usingSpringWithDamping:.8 initialSpringVelocity:1.5 options:UIViewAnimationOptionTransitionNone animations:^{
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
}completion:^(BOOL finished) {
}];
在animateWithDuration block 之外设置clearColor使动画平滑十亿倍。现在它的动画效果很好
关于ios - 在 2 个 ViewController 之间推送 - NavigationBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26486439/