// 设置导航栏透明
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
_barImgView = self.navigationController.navigationBar.subviews.firstObject
// 设置颜色
_barImgView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:1];
// 下滑显示和上滑透明
CGFloat alaph = ((scrollView.contentOffset.y ) /250.0);
NSLog(@"值1:--%f,alaph值:--%f", (scrollView.contentOffset.y ) / 250.0, alaph);
alaph = alaph < 0 ?0 : alaph;
_barImgView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:alaph];
(直接使用_barImgView.alaph 返回时回导航栏的颜色颜色会有问题)