From 3b0d04998a3d16642d6deef070b32bc701a6ea59 Mon Sep 17 00:00:00 2001 From: acton393 Date: Fri, 31 Mar 2017 18:18:45 +0800 Subject: [PATCH 1/3] * [ios] refactor gradient-color method --- ios/sdk/WeexSDK.xcodeproj/project.pbxproj | 8 -- .../Component/WXComponent+GradientColor.h | 18 --- .../Component/WXComponent+GradientColor.m | 124 ------------------ .../Sources/Component/WXComponent_internal.h | 3 + .../Sources/Layout/WXComponent+Layout.m | 1 - ios/sdk/WeexSDK/Sources/Model/WXComponent.m | 29 +++- ios/sdk/WeexSDK/Sources/Utility/WXUtility.h | 27 ++++ ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 101 ++++++++++++++ .../Sources/View/WXComponent+ViewManagement.m | 1 - 9 files changed, 159 insertions(+), 153 deletions(-) delete mode 100644 ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.h delete mode 100644 ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.m diff --git a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj index f861bd97b8..6ba204b5a3 100644 --- a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj +++ b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj @@ -51,8 +51,6 @@ 598805AD1D52D8C800EDED2C /* WXStorageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 598805AC1D52D8C800EDED2C /* WXStorageTests.m */; }; 5996BD701D49EC0600C0FEA6 /* WXInstanceWrapTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5996BD6F1D49EC0600C0FEA6 /* WXInstanceWrapTests.m */; }; 5996BD751D4D8A0E00C0FEA6 /* WXSDKEngineTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5996BD741D4D8A0E00C0FEA6 /* WXSDKEngineTests.m */; }; - 59970D2E1E0D228D0049F535 /* WXComponent+GradientColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 59970D2C1E0D228D0049F535 /* WXComponent+GradientColor.h */; }; - 59970D2F1E0D228D0049F535 /* WXComponent+GradientColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 59970D2D1E0D228D0049F535 /* WXComponent+GradientColor.m */; }; 59A582D41CF481110081FD3E /* WXAppMonitorProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A582D31CF481110081FD3E /* WXAppMonitorProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 59A582FC1CF5B17B0081FD3E /* WXBridgeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A582FA1CF5B17B0081FD3E /* WXBridgeContext.h */; }; 59A582FD1CF5B17B0081FD3E /* WXBridgeContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A582FB1CF5B17B0081FD3E /* WXBridgeContext.m */; }; @@ -362,8 +360,6 @@ 598805AC1D52D8C800EDED2C /* WXStorageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXStorageTests.m; sourceTree = ""; }; 5996BD6F1D49EC0600C0FEA6 /* WXInstanceWrapTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXInstanceWrapTests.m; sourceTree = ""; }; 5996BD741D4D8A0E00C0FEA6 /* WXSDKEngineTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXSDKEngineTests.m; sourceTree = ""; }; - 59970D2C1E0D228D0049F535 /* WXComponent+GradientColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WXComponent+GradientColor.h"; sourceTree = ""; }; - 59970D2D1E0D228D0049F535 /* WXComponent+GradientColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "WXComponent+GradientColor.m"; sourceTree = ""; }; 59A582D31CF481110081FD3E /* WXAppMonitorProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXAppMonitorProtocol.h; sourceTree = ""; }; 59A582FA1CF5B17B0081FD3E /* WXBridgeContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXBridgeContext.h; sourceTree = ""; }; 59A582FB1CF5B17B0081FD3E /* WXBridgeContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXBridgeContext.m; sourceTree = ""; }; @@ -1137,8 +1133,6 @@ 741081251CEDB4EC001BC6E5 /* WXComponent_internal.h */, D33451061D3E19480083598A /* WXCanvasComponent.h */, D33451071D3E19480083598A /* WXCanvasComponent.m */, - 59970D2C1E0D228D0049F535 /* WXComponent+GradientColor.h */, - 59970D2D1E0D228D0049F535 /* WXComponent+GradientColor.m */, 744D610A1E49978200B624B3 /* WXHeaderComponent.h */, 744D610B1E49978200B624B3 /* WXHeaderComponent.m */, 744D610E1E49979000B624B3 /* WXFooterComponent.h */, @@ -1321,7 +1315,6 @@ D317338C1C57257000BB7539 /* WXTransform.h in Headers */, 77D161301C02DE4E0010B15B /* WXComponent.h in Headers */, 2AFEB17B1C747139000507FA /* WXInstanceWrap.h in Headers */, - 59970D2E1E0D228D0049F535 /* WXComponent+GradientColor.h in Headers */, 744BEA551D05178F00452B5D /* WXComponent+Display.h in Headers */, 741081231CED6756001BC6E5 /* WXComponentFactory.h in Headers */, 59D3CA4A1CFC3CE1008835DC /* NSTimer+Weex.h in Headers */, @@ -1629,7 +1622,6 @@ 749DC27C1D40827B009E1C91 /* WXMonitor.m in Sources */, C4B834271DE69B09007AD27E /* WXPickerModule.m in Sources */, C4F0127A1E1502A6003378D0 /* SRWebSocket+Weex.m in Sources */, - 59970D2F1E0D228D0049F535 /* WXComponent+GradientColor.m in Sources */, 745B2D691E5A8E1E0092D38A /* WXMultiColumnLayout.m in Sources */, 77D161391C02DE940010B15B /* WXBridgeManager.m in Sources */, ); diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.h deleted file mode 100644 index bded90864c..0000000000 --- a/ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Created by Weex. - * Copyright (c) 2016, Alibaba, Inc. All rights reserved. - * - * This source code is licensed under the Apache Licence 2.0. - * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. - */ - - -#import -#import -#import "WXComponent.h" -#import "WXType.h" - -@interface WXComponent (GradientColor) - -- (void)setGradientLayer; -@end diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.m b/ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.m deleted file mode 100644 index eae772c656..0000000000 --- a/ios/sdk/WeexSDK/Sources/Component/WXComponent+GradientColor.m +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Created by Weex. - * Copyright (c) 2016, Alibaba, Inc. All rights reserved. - * - * This source code is licensed under the Apache Licence 2.0. - * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. - */ - -#import "WXComponent+GradientColor.h" -#import "WXComponent_internal.h" -#import "WXConvert.h" - -@implementation WXComponent (GradientColor) - -- (void)setGradientLayer -{ - if (CGRectEqualToRect(self.view.frame, CGRectZero)) { - return; - } - //parse gradient-color, linear-gradient(to right, #a80077,rgba(200, 54, 54, 0.5)) - if ([_backgroundImage hasPrefix:@"linear-gradient"] && [_backgroundImage hasSuffix:@")"] ) { - NSRange range = NSMakeRange(16, _backgroundImage.length - 17); - NSString *str = [_backgroundImage substringWithRange:range]; - NSArray *array = [str componentsSeparatedByString:@","]; - WXGradientType gradientType; - UIColor *startColor, *endColor; - - if ([array count] == 3) { - gradientType = [WXConvert gradientType:array[0]]; - startColor = [WXConvert UIColor:array[1]]; - endColor = [WXConvert UIColor:array[2]]; - } - else if ([array count] > 3){ - NSString *gradientTypeStr = array[0]; - NSString *subStr = [str substringFromIndex:gradientTypeStr.length + 1]; - - if ([subStr hasPrefix:@"rgb"]) { - gradientType = [WXConvert gradientType:gradientTypeStr]; - - range = [subStr rangeOfString:@")"]; - NSString *startColorStr = [subStr substringToIndex:range.location + 1]; - NSString *endColorStr = [subStr substringFromIndex:range.location + 2]; - startColor = [WXConvert UIColor:startColorStr]; - endColor = [WXConvert UIColor:endColorStr]; - } - else { - gradientType = [WXConvert gradientType:gradientTypeStr]; - - startColor = [WXConvert UIColor:array[1]]; - - NSString *startColorStr = array[1]; - NSString *endColorStr = [subStr substringFromIndex:startColorStr.length + 1]; - endColor = [WXConvert UIColor:endColorStr]; - } - } - else { - return; - } - - __weak typeof(self) weakSelf = self; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - CAGradientLayer * gradientLayer = [weakSelf gradientLayerFromColors:@[startColor, endColor] gradientType:gradientType]; - dispatch_async(dispatch_get_main_queue(), ^{ - __strong typeof(self) strongSelf = weakSelf; - /* - must insert the gradientLayer at index 0, and then set masksToBounds to match the view bounds - or the subview will be invisible - */ - if(strongSelf) { - [strongSelf.view.layer insertSublayer:gradientLayer atIndex:0]; - strongSelf.view.layer.masksToBounds = YES; - } - }); - }); - } -} - -- (CAGradientLayer*)gradientLayerFromColors:(NSArray*)colors gradientType:(WXGradientType)gradientType -{ - CAGradientLayer * gradientLayer = [CAGradientLayer layer]; - NSMutableArray *newColors = [NSMutableArray array]; - for(UIColor *color in colors) { - [newColors addObject:(id)color.CGColor]; - } - gradientLayer.colors = newColors; - CGPoint start; - CGPoint end; - switch (gradientType) { - case WXGradientTypeToTop: - start = CGPointMake(0.0, 1.0); - end = CGPointMake(0.0, 0.0); - break; - case WXGradientTypeToBottom: - start = CGPointMake(0.0, 0.0); - end = CGPointMake(0.0, 1.0); - break; - case WXGradientTypeToLeft: - start = CGPointMake(1.0, 0.0); - end = CGPointMake(0.0, 0.0); - break; - case WXGradientTypeToRight: - start = CGPointMake(0.0, 0.0); - end = CGPointMake(1.0, 0.0); - break; - case WXGradientTypeToTopleft: - start = CGPointMake(1.0, 1.0); - end = CGPointMake(0.0, 0.0f); - break; - case WXGradientTypeToBottomright: - start = CGPointMake(0.0, 0.0); - end = CGPointMake(1.0, 1.0); - break; - default: - break; - } - - gradientLayer.startPoint = start; - gradientLayer.endPoint = end; - gradientLayer.frame = self.view.bounds; - - return gradientLayer; -} - -@end diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h index 98520b86b8..28f9d2ee04 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h +++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h @@ -196,4 +196,7 @@ - (void)_restoreViewStyles; - (void)_configWXComponentA11yWithAttributes:(NSDictionary *)attributes; + +- (void)setGradientLayer; + @end diff --git a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m index 350f9e29f3..e05ac4609f 100644 --- a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m +++ b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m @@ -13,7 +13,6 @@ #import "WXComponent_internal.h" #import "WXSDKInstance_private.h" #import "WXComponent+BoxShadow.h" -#import "WXComponent+GradientColor.h" @implementation WXComponent (Layout) diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m index ba5752a571..cecc708935 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m +++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m @@ -8,7 +8,6 @@ #import "WXComponent.h" #import "WXComponent_internal.h" -#import "WXComponent+GradientColor.h" #import "WXComponentManager.h" #import "WXSDKManager.h" #import "WXSDKInstance.h" @@ -451,6 +450,34 @@ - (void)updateAttributes:(NSDictionary *)attributes } +- (void)setGradientLayer +{ + if (CGRectEqualToRect(self.view.frame, CGRectZero)) { + return; + } + NSDictionary * linearGradient = [WXUtility linearGradientWithBackgroundImage:_backgroundImage]; + if (!linearGradient) { + return ; + } + + __weak typeof(self) weakSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + __strong typeof(self) strongSelf = weakSelf; + /* + must insert the gradientLayer at index 0, and then set masksToBounds to match the view bounds + or the subview will be invisible + */ + + if(strongSelf) { + UIColor * startColor = (UIColor*)linearGradient[@"startColor"]; + UIColor * endColor = (UIColor*)linearGradient[@"endColor"]; + CAGradientLayer * gradientLayer = [WXUtility gradientLayerFromColors:@[startColor, endColor] locations:nil frame:strongSelf.view.bounds gradientType:[linearGradient[@"gradientType"] integerValue]]; + [strongSelf.view.layer insertSublayer:gradientLayer atIndex:0]; + strongSelf.view.layer.masksToBounds = YES; + } + }); +} + - (void)_configWXComponentA11yWithAttributes:(NSDictionary *)attributes { if (attributes[@"role"]){ diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h index d8950d1c82..04b6ce9a75 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h +++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h @@ -357,6 +357,33 @@ CGRect WXPixelFrameResize(CGRect value) DEPRECATED_MSG_ATTRIBUTE("Use WXPixelSca CGPoint WXPixelPointResize(CGPoint value) DEPRECATED_MSG_ATTRIBUTE("Use WXPixelScale Instead"); + (UIFont * _Nullable )fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:(WXTextStyle)textStyle fontFamily:(NSString * _Nullable)fontFamily DEPRECATED_MSG_ATTRIBUTE("Use +[WXUtility fontWithSize:textWeight:textStyle:fontFamily:scaleFactor:]"); + +/** + @discusstion construct a gradientLayer from the colors locations, gradientType + @param colors The array of UIColor objects defining the color of each gradient + stop. Defaults to nil + @param locations An optional array of NSNumber objects defining the location of each + gradient stop as a value in the range [0,1]. + @param frame the layer frame + @param gradientType WXGradientType value specify the gradient location + @return gradient layer + */ ++ (CAGradientLayer *_Nullable)gradientLayerFromColors:(NSArray*_Nullable)colors + locations:(NSArray*_Nullable)locations + frame:(CGRect)frame + gradientType:(WXGradientType)gradientType; + +/** + @discusstion parse gradient-color string to a dictionary, then you can get gradientLayer from @see gradientLayerFromColors:colors:locations:frame:locations + @param a linear-gradient string like linear-gradient(to right, #a80077,rgba(200, 54, 54, 0.5)) + @return A dictionary with endColor, startColor and gradientType value + @code + NSDictionary * linearGradient = [self linearGradientWithBackgroundImage:@"linear-gradient(to right, #a80077,rgba(200, 54, 54, 0.5))"]; + CAGradientLayer * gradientLayer = [self gradientLayerFromColors:@[linearGradient[@"startColor"], linearGradient[@"endColor"]],nil,bounds,[linearGradient[@"gradientType"] integerValue]]; + @endcode + */ ++ (NSDictionary *_Nullable)linearGradientWithBackgroundImage:(NSString *_Nullable)backgroundImage; + /** * @abstract compare float a and b, if a equal b, return true,or reture false. * diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m index 19fe04cd7c..4677dbc251 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m +++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m @@ -13,6 +13,7 @@ #import "WXThreadSafeMutableDictionary.h" #import "WXRuleManager.h" #import "WXSDKEngine.h" +#import "WXConvert.h" #import #import #import @@ -325,6 +326,106 @@ + (NSError *)errorWithCode:(NSInteger)code message:(NSString *)message return [NSError errorWithDomain:@"WeexErrorDomain" code:code userInfo:@{@"errMsg":message}]; } ++ (NSDictionary *)linearGradientWithBackgroundImage:(NSString *)backgroundImage +{ + NSMutableDictionary * linearGradient = nil; + if ([backgroundImage hasPrefix:@"linear-gradient"] && [backgroundImage hasSuffix:@")"] ) { + NSRange range = NSMakeRange(16, backgroundImage.length - 17); + NSString *str = [backgroundImage substringWithRange:range]; + NSArray *array = [str componentsSeparatedByString:@","]; + WXGradientType gradientType; + UIColor *startColor, *endColor; + if ([array count] < 3) { + return linearGradient; + } + if ([array count] == 3) { + gradientType = [WXConvert gradientType:array[0]]; + startColor = [WXConvert UIColor:array[1]]; + endColor = [WXConvert UIColor:array[2]]; + } else if ([array count] > 3) { + NSString *gradientTypeStr = array[0]; + NSString *subStr = [str substringFromIndex:gradientTypeStr.length + 1]; + if ([subStr hasPrefix:@"rgb"]) { + gradientType = [WXConvert gradientType:gradientTypeStr]; + + range = [subStr rangeOfString:@")"]; + NSString *startColorStr = [subStr substringToIndex:range.location + 1]; + NSString *endColorStr = [subStr substringFromIndex:range.location + 2]; + startColor = [WXConvert UIColor:startColorStr]; + endColor = [WXConvert UIColor:endColorStr]; + } + else { + gradientType = [WXConvert gradientType:gradientTypeStr]; + + startColor = [WXConvert UIColor:array[1]]; + + NSString *startColorStr = array[1]; + NSString *endColorStr = [subStr substringFromIndex:startColorStr.length + 1]; + endColor = [WXConvert UIColor:endColorStr]; + } + } + + if (endColor || startColor) { + linearGradient = [NSMutableDictionary new]; + [linearGradient setValue:startColor forKey:@"startColor"]; + [linearGradient setValue:endColor forKey:@"endColor"]; + [linearGradient setValue:@(gradientType) forKey:@"gradientType"]; + } + } + return linearGradient; +} + ++ (CAGradientLayer *)gradientLayerFromColors:(NSArray*)colors locations:(NSArray*)locations frame:(CGRect)frame gradientType:(WXGradientType)gradientType +{ + CAGradientLayer * gradientLayer = [CAGradientLayer layer]; + NSMutableArray *newColors = [NSMutableArray new]; + for(UIColor *color in colors) { + [newColors addObject:(id)color.CGColor]; + } + if (colors) { + gradientLayer.colors = newColors; + } + if (locations) { + gradientLayer.locations = locations; + } + CGPoint start = CGPointZero; + CGPoint end = CGPointZero; + switch (gradientType) { + case WXGradientTypeToTop: + start = CGPointMake(0.0, 1.0); + end = CGPointMake(0.0, 0.0); + break; + case WXGradientTypeToBottom: + start = CGPointMake(0.0, 0.0); + end = CGPointMake(0.0, 1.0); + break; + case WXGradientTypeToLeft: + start = CGPointMake(1.0, 0.0); + end = CGPointMake(0.0, 0.0); + break; + case WXGradientTypeToRight: + start = CGPointMake(0.0, 0.0); + end = CGPointMake(1.0, 0.0); + break; + case WXGradientTypeToTopleft: + start = CGPointMake(1.0, 1.0); + end = CGPointMake(0.0, 0.0f); + break; + case WXGradientTypeToBottomright: + start = CGPointMake(0.0, 0.0); + end = CGPointMake(1.0, 1.0); + break; + default: + break; + } + + gradientLayer.startPoint = start; + gradientLayer.endPoint = end; + gradientLayer.frame = frame; + + return gradientLayer; +} + + (UIFont *)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle:(WXTextStyle)textStyle fontFamily:(NSString *)fontFamily { return [self fontWithSize:size textWeight:textWeight textStyle:textStyle fontFamily:fontFamily scaleFactor:[self defaultPixelScaleFactor]]; diff --git a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m index ffc4922b2a..9108f8ade1 100644 --- a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m +++ b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m @@ -8,7 +8,6 @@ #import "WXComponent+ViewManagement.h" #import "WXComponent_internal.h" -#import "WXComponent+GradientColor.h" #import "WXComponent+BoxShadow.h" #import "WXAssert.h" #import "WXView.h" From 9553bd41d62f2ff02ef3756d3a9547345514025b Mon Sep 17 00:00:00 2001 From: acton393 Date: Fri, 31 Mar 2017 18:20:48 +0800 Subject: [PATCH 2/3] * [ios] add default value --- ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m index 4677dbc251..aeb85a5b90 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m +++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m @@ -333,7 +333,7 @@ + (NSDictionary *)linearGradientWithBackgroundImage:(NSString *)backgroundImage NSRange range = NSMakeRange(16, backgroundImage.length - 17); NSString *str = [backgroundImage substringWithRange:range]; NSArray *array = [str componentsSeparatedByString:@","]; - WXGradientType gradientType; + WXGradientType gradientType = WXGradientTypeToTop; UIColor *startColor, *endColor; if ([array count] < 3) { return linearGradient; From a44a946f830ed7e7ef0628f9073d8be77e0dd788 Mon Sep 17 00:00:00 2001 From: acton393 Date: Fri, 31 Mar 2017 18:22:51 +0800 Subject: [PATCH 3/3] * [ios] fix box shadow shadowColor get method circularly called --- ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m b/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m index 454be39e63..7ba51f2ff5 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m +++ b/ios/sdk/WeexSDK/Sources/Utility/WXBoxShadow.m @@ -11,10 +11,11 @@ #import "WXUtility.h" @implementation WXBoxShadow +@synthesize shadowColor = _shadowColor; - (void) dealloc { - CGColorRelease(self.shadowColor); + CGColorRelease(_shadowColor); } - (instancetype)init @@ -32,17 +33,17 @@ - (instancetype)init } - (CGColorRef)shadowColor { - return self.shadowColor; + return _shadowColor; } - (void)setShadowColor: (CGColorRef)shadowColor { - if (shadowColor == self.shadowColor) + if (shadowColor == _shadowColor) return; CGColorRetain(shadowColor); - CGColorRelease(self.shadowColor); - self.shadowColor = shadowColor; + CGColorRelease(_shadowColor); + _shadowColor = shadowColor; } + (NSArray *)getBoxShadowElementsByBlank:(NSString *)string