|
@@ -10,7 +10,10 @@
|
|
|
#import "RAOrderDetailViewController.h"
|
|
#import "RAOrderDetailViewController.h"
|
|
|
|
|
|
|
|
@interface RANavigationController ()
|
|
@interface RANavigationController ()
|
|
|
-
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ CAGradientLayer *_gradientLayer;
|
|
|
|
|
+ UIView *_barBackgroundView, *_gradientView;
|
|
|
|
|
+}
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@implementation RANavigationController
|
|
@implementation RANavigationController
|
|
@@ -20,10 +23,41 @@
|
|
|
// Do any additional setup after loading the view.
|
|
// Do any additional setup after loading the view.
|
|
|
[self _configAppearance];
|
|
[self _configAppearance];
|
|
|
[self registNotification];
|
|
[self registNotification];
|
|
|
|
|
+
|
|
|
|
|
+ _gradientLayer = [CAGradientLayer layer];
|
|
|
|
|
+
|
|
|
|
|
+ UIColor *orangeWhiteColor = ApexDriverOrangeWhiteColor;
|
|
|
|
|
+ UIColor *orangeColor = ApexDriverOrangeColor;
|
|
|
|
|
+// _gradientLayer.colors = @[(__bridge id)orangeWhiteColor.CGColor, (__bridge id)orangeColor.CGColor];
|
|
|
|
|
+ _gradientLayer.colors = @[(__bridge id)orangeColor.CGColor, (__bridge id)orangeWhiteColor.CGColor];
|
|
|
|
|
+
|
|
|
|
|
+ _gradientLayer.startPoint = CGPointMake(0, 0);
|
|
|
|
|
+ _gradientLayer.endPoint = CGPointMake(1, 0);
|
|
|
|
|
+// _gradientLayer.locations = @[@0,@0.2];
|
|
|
|
|
+
|
|
|
|
|
+ _barBackgroundView = [self.navigationBar.subviews objectAtIndex:0];
|
|
|
|
|
+
|
|
|
|
|
+ _gradientView = [UIView new];
|
|
|
|
|
+ _gradientView.frame = _barBackgroundView.bounds;
|
|
|
|
|
+ _gradientLayer.frame = _gradientView.bounds;
|
|
|
|
|
+
|
|
|
|
|
+ [_gradientView.layer addSublayer:_gradientLayer];
|
|
|
|
|
+ [_barBackgroundView addSubview:_gradientView];
|
|
|
|
|
+
|
|
|
|
|
+ [_barBackgroundView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:(__bridge void * _Nullable)(self)];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
|
|
|
|
|
+ if (context == (__bridge void * _Nullable)(self)) {
|
|
|
|
|
+
|
|
|
|
|
+ _gradientView.frame = _barBackgroundView.bounds;
|
|
|
|
|
+ _gradientLayer.frame = _gradientView.bounds;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc {
|
|
- (void)dealloc {
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
|
+ [_barBackgroundView removeObserver:self forKeyPath:@"bounds"];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
- (void)didReceiveMemoryWarning {
|
|
@@ -41,7 +75,11 @@
|
|
|
[self.navigationBar setTintColor:ApexDriverWhiteColor]; // BarItem颜色
|
|
[self.navigationBar setTintColor:ApexDriverWhiteColor]; // BarItem颜色
|
|
|
self.navigationBar.barTintColor = ApexDriverOrangeColor; // 背景色
|
|
self.navigationBar.barTintColor = ApexDriverOrangeColor; // 背景色
|
|
|
self.navigationBar.translucent = NO;
|
|
self.navigationBar.translucent = NO;
|
|
|
- self.navigationBar.shadowImage = [UIImage new]; // 去除Bar黑色分割线
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 去除Bar黑色分割线
|
|
|
|
|
+ self.navigationBar.shadowImage = [UIImage new];
|
|
|
|
|
+ [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)registNotification {
|
|
- (void)registNotification {
|