Bladeren bron

1.修改iOS Apex Drivers Home渐变色。

Pen Li 7 jaren geleden
bovenliggende
commit
53db6b296e

+ 23 - 1
Redant Drivers/Apex And Drivers/Home/RAHomeHeaderView.m

@@ -9,6 +9,9 @@
 #import "RAHomeHeaderView.h"
 
 @interface RAHomeHeaderView ()
+{
+    CAGradientLayer *_gradientLayer;
+}
 
 @property (nonatomic,strong) IBOutlet UILabel *NewCountLabel;
 @property (nonatomic,strong) IBOutlet UILabel *ProcessingCountLabel;
@@ -38,7 +41,26 @@
     self.NewOrderCount = self.ProcessingOrderCount = self.FinishOrderCount = 0;
     self.availabel = self.existNewMessage = NO;
     
-    self.backgroundView.backgroundColor = ApexDriverOrangeColor;
+//    self.backgroundView.backgroundColor = ApexDriverOrangeColor;
+    
+    _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];
+    _gradientLayer.frame = self.backgroundView.bounds;
+    [self.backgroundView.layer addSublayer:_gradientLayer];
+}
+
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    
+    _gradientLayer.frame = self.backgroundView.bounds;
 }
 
 - (void)setNewOrderCount:(NSInteger)NewOrderCount {

+ 40 - 2
Redant Drivers/Apex And Drivers/RANavigationController.m

@@ -10,7 +10,10 @@
 #import "RAOrderDetailViewController.h"
 
 @interface RANavigationController ()
-
+{
+    CAGradientLayer *_gradientLayer;
+    UIView *_barBackgroundView, *_gradientView;
+}
 @end
 
 @implementation RANavigationController
@@ -20,10 +23,41 @@
     // Do any additional setup after loading the view.
     [self _configAppearance];
     [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 {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [_barBackgroundView removeObserver:self forKeyPath:@"bounds"];
 }
 
 - (void)didReceiveMemoryWarning {
@@ -41,7 +75,11 @@
     [self.navigationBar setTintColor:ApexDriverWhiteColor]; // BarItem颜色
     self.navigationBar.barTintColor = ApexDriverOrangeColor; // 背景色
     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 {

+ 1 - 0
Redant Drivers/Apex And Drivers/config.h

@@ -9,6 +9,7 @@
 #ifndef config_h
 #define config_h
 
+#define ApexDriverOrangeWhiteColor UIColorFromRGB(0xff5555)
 #define ApexDriverOrangeColor UIColorFromRGB(0xEC6C23)
 #define ApexDriverGrayColor UIColorFromRGB(0x4f5356)
 #define ApexDriverWhiteColor UIColorFromRGB(0xffffff)

+ 1 - 0
Redant Drivers/Apex And Drivers/const.h

@@ -29,6 +29,7 @@
 #endif
 
 #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
+#define UIColorFromRGBAlpha(rgbValue,alp) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(alp)]
 
 #define URL_REMOTE 1
 #define URL_LOCAL 0