You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/03/31 15:52:39 UTC

incubator-weex git commit: + [ios] change to color

Repository: incubator-weex
Updated Branches:
  refs/heads/0.12-dev a52afae75 -> 355512595


+ [ios] change to color


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/35551259
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/35551259
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/35551259

Branch: refs/heads/0.12-dev
Commit: 3555125958968f44b95e43e29672ed65af639d8d
Parents: a52afae
Author: \u9f50\u5c71 <su...@163.com>
Authored: Fri Mar 31 21:03:29 2017 +0800
Committer: \u9f50\u5c71 <su...@163.com>
Committed: Fri Mar 31 21:03:29 2017 +0800

----------------------------------------------------------------------
 .../Sources/Display/WXComponent+BoxShadow.h     |  2 +-
 .../Sources/Display/WXComponent+BoxShadow.m     | 10 ++++-----
 ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.h  |  2 +-
 ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.m  |  4 ++--
 .../WeexSDK/Sources/Layout/WXComponent+Layout.m |  2 +-
 ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.h   |  2 +-
 ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m   | 23 ++------------------
 7 files changed, 13 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35551259/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.h b/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.h
index 2c1a645..d7fe12e 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.h
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.h
@@ -21,7 +21,7 @@
  *
  *  @return if not equal return NO, if equal return YES
  */
-- (BOOL)EqualBoxShadow:(WXBoxShadow *_Nullable)boxShadow withBoxShadow:(WXBoxShadow *_Nullable)compareBoxShadow;
+- (BOOL)equalBoxShadow:(WXBoxShadow *_Nullable)boxShadow withBoxShadow:(WXBoxShadow *_Nullable)compareBoxShadow;
 
 /**
  *  @abstract config view Layer with boxshadow, lastboxshadow and originalBoxShadow

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35551259/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
index ba9927b..6b8a7a7 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+BoxShadow.m
@@ -18,7 +18,7 @@
 - (WXBoxShadow *_Nullable)getViewBoxShadow:(UIView *_Nullable)view
 {
     WXBoxShadow *boxShadow = [WXBoxShadow new];
-    boxShadow.shadowColor = view.layer.shadowColor;
+    boxShadow.shadowColor = [UIColor colorWithCGColor:view.layer.shadowColor];
     boxShadow.shadowOffset = view.layer.shadowOffset;
     boxShadow.shadowRadius = view.layer.shadowRadius;
     boxShadow.shadowOpacity =  view.layer.shadowOpacity;
@@ -29,7 +29,7 @@
 {
     UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds];
     self.view.layer.masksToBounds = NO;
-    self.view.layer.shadowColor = _originalBoxShadow.shadowColor;
+    self.view.layer.shadowColor = _originalBoxShadow.shadowColor.CGColor;
     self.view.layer.shadowOffset = _originalBoxShadow.shadowOffset;
     self.view.layer.shadowRadius = _originalBoxShadow.shadowRadius;
     self.view.layer.shadowOpacity = _originalBoxShadow.shadowOpacity;
@@ -44,11 +44,11 @@
 }
 
 // if not equal return NO, if equal return YES
-- (BOOL)EqualBoxShadow:(WXBoxShadow *_Nullable)boxShadow withBoxShadow:(WXBoxShadow *_Nullable)compareBoxShadow
+- (BOOL)equalBoxShadow:(WXBoxShadow *_Nullable)boxShadow withBoxShadow:(WXBoxShadow *_Nullable)compareBoxShadow
 {
     if(!compareBoxShadow && !boxShadow) {
         return YES;
-    } else if (CGColorEqualToColor(boxShadow.shadowColor,compareBoxShadow.shadowColor) &&
+    } else if (CGColorEqualToColor(boxShadow.shadowColor.CGColor,compareBoxShadow.shadowColor.CGColor) &&
                CGSizeEqualToSize(boxShadow.shadowOffset,compareBoxShadow.shadowOffset) &&
                WXFloatEqual(boxShadow.shadowRadius,compareBoxShadow.shadowRadius)&& (boxShadow.isInset == compareBoxShadow.isInset))
     {
@@ -80,7 +80,7 @@
     } else {
         UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds];
         self.view.layer.masksToBounds = NO;
-        self.view.layer.shadowColor = boxShadow.shadowColor;
+        self.view.layer.shadowColor = boxShadow.shadowColor.CGColor;
         self.view.layer.shadowOffset = boxShadow.shadowOffset;
         self.view.layer.shadowRadius = boxShadow.shadowRadius;
         self.view.layer.shadowOpacity = boxShadow.shadowOpacity;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35551259/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.h b/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.h
index f3b2bf4..82337de 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.h
+++ b/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.h
@@ -12,7 +12,7 @@
 @interface WXInnerLayer : CAGradientLayer
 
 @property CGFloat boxShadowRadius;
-@property CGColorRef boxShadowColor;
+@property (nonatomic,strong) UIColor *boxShadowColor;
 @property CGSize boxShadowOffset;
 @property CGFloat boxShadowOpacity;
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35551259/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.m b/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.m
index e49c5b6..4029ddb 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXInnerLayer.m
@@ -50,9 +50,9 @@
     CGPathAddRect(outer, NULL, CGRectInset(rect, -1*rect.size.width, -1*rect.size.height));
     CGPathAddPath(outer, NULL, bezierPath.CGPath);
     CGPathCloseSubpath(outer);
-    CGFloat *oldComponents = (CGFloat *)CGColorGetComponents(self.boxShadowColor);
+    CGFloat *oldComponents = (CGFloat *)CGColorGetComponents(self.boxShadowColor.CGColor);
     CGFloat newComponents[4];
-    NSInteger numberOfComponents = CGColorGetNumberOfComponents(self.boxShadowColor);
+    NSInteger numberOfComponents = CGColorGetNumberOfComponents(self.boxShadowColor.CGColor);
     switch (numberOfComponents)
     {
         case 2:

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35551259/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
index 350f9e2..ca24026 100644
--- a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
+++ b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
@@ -122,7 +122,7 @@
                 strongSelf.view.frame = strongSelf.calculatedFrame;
                 [strongSelf configBoxShadow:_boxShadow];
             } else {
-                if (![strongSelf EqualBoxShadow:_boxShadow withBoxShadow:_lastBoxShadow]) {
+                if (![strongSelf equalBoxShadow:_boxShadow withBoxShadow:_lastBoxShadow]) {
                     [strongSelf configBoxShadow:_boxShadow];
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35551259/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.h b/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.h
index 01dfa5c..5f0faee 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.h
@@ -11,7 +11,7 @@
 
 @interface WXBoxShadow : NSObject
 
-@property(nullable) CGColorRef shadowColor;
+@property(nonatomic,strong,nullable) UIColor *shadowColor;
 @property CGSize shadowOffset;
 @property CGFloat shadowRadius;
 @property BOOL isInset;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35551259/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m b/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m
index 454be39..4cb9181 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m
@@ -12,11 +12,6 @@
 
 @implementation WXBoxShadow
 
-- (void) dealloc
-{
-    CGColorRelease(self.shadowColor);
-}
-
 - (instancetype)init
 {
     self = [super init];
@@ -31,20 +26,6 @@
     return self;
 }
 
-- (CGColorRef)shadowColor {
-    return self.shadowColor;
-}
-
-- (void)setShadowColor: (CGColorRef)shadowColor
-{
-    if (shadowColor == self.shadowColor)
-    return;
-    
-    CGColorRetain(shadowColor);
-    CGColorRelease(self.shadowColor);
-    self.shadowColor = shadowColor;
-}
-
 + (NSArray *)getBoxShadowElementsByBlank:(NSString *)string
 {
     string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
@@ -77,7 +58,7 @@
             NSString *str = [string substringWithRange:range];
             UIColor *color = [WXConvert UIColor:str];
             if (color && [color isKindOfClass:[UIColor class]]) {
-                boxShadow.shadowColor = color.CGColor;
+                boxShadow.shadowColor = color;
             }
             string = [string stringByReplacingOccurrencesOfString:str withString:@""];// remove color string
         }
@@ -86,7 +67,7 @@
         NSString *str = [boxShadowElements lastObject];
         UIColor *color = [WXConvert UIColor:str];
         if (color && [color isKindOfClass:[UIColor class]]) {
-            boxShadow.shadowColor = color.CGColor;
+            boxShadow.shadowColor = color;
         }
         string = [string stringByReplacingOccurrencesOfString:str withString:@""];// remove color string
     }