From 4d6884098c3d9e28dd88a89aca17724cc5fb4c05 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 20 Mar 2020 15:27:31 +0800 Subject: [PATCH] iOS:fix NSNull Crash --- doric-iOS/Pod/Classes/Shader/DoricViewNode.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricViewNode.m b/doric-iOS/Pod/Classes/Shader/DoricViewNode.m index 066eba43..b6e4225a 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricViewNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricViewNode.m @@ -138,6 +138,9 @@ - (void)blend:(NSDictionary *)props { self.view.layoutConfig = self.layoutConfig; for (NSString *key in props) { id value = props[key]; + if (!value || [value isKindOfClass:[NSNull class]]) { + continue; + } [self blendView:self.view forPropName:key propValue:value]; } [self transformProperties]; @@ -190,12 +193,12 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop _gradientLayer = [[CAGradientLayer alloc] init]; [view.layer addSublayer:self.gradientLayer]; } - + NSDictionary *dict = prop; UIColor *start = DoricColor(dict[@"start"]); UIColor *end = DoricColor(dict[@"end"]); int orientation = [dict[@"orientation"] intValue]; - + if (orientation == 0) { self.gradientLayer.startPoint = CGPointMake(0, 0); self.gradientLayer.endPoint = CGPointMake(0, 1); @@ -221,7 +224,7 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop self.gradientLayer.startPoint = CGPointMake(0, 0); self.gradientLayer.endPoint = CGPointMake(1, 1); } - self.gradientLayer.colors = @[(__bridge id)start.CGColor, (__bridge id)end.CGColor]; + self.gradientLayer.colors = @[(__bridge id) start.CGColor, (__bridge id) end.CGColor]; } } else if ([name isEqualToString:@"alpha"]) { view.alpha = [prop floatValue];