iOS:fix gradiantlayer frame nil

This commit is contained in:
pengfei.zhou 2020-03-23 13:12:32 +08:00 committed by osborn
parent c97bc26de0
commit 7408d9cfed

View File

@ -144,6 +144,7 @@ - (void)blend:(NSDictionary *)props {
[self blendView:self.view forPropName:key propValue:value]; [self blendView:self.view forPropName:key propValue:value];
} }
[self transformProperties]; [self transformProperties];
self.gradientLayer.frame = CGRectMake(0, 0, self.view.width, self.view.height);
} }
- (void)transformProperties { - (void)transformProperties {
@ -173,13 +174,11 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
NSNumber *width = (NSNumber *) prop; NSNumber *width = (NSNumber *) prop;
if ([width floatValue] >= 0) { if ([width floatValue] >= 0) {
view.width = [width floatValue]; view.width = [width floatValue];
self.gradientLayer.frame = view.bounds;
} }
} else if ([name isEqualToString:@"height"]) { } else if ([name isEqualToString:@"height"]) {
NSNumber *height = (NSNumber *) prop; NSNumber *height = (NSNumber *) prop;
if ([height floatValue] >= 0) { if ([height floatValue] >= 0) {
view.height = [height floatValue]; view.height = [height floatValue];
self.gradientLayer.frame = view.bounds;
} }
} else if ([name isEqualToString:@"x"]) { } else if ([name isEqualToString:@"x"]) {
view.x = [prop floatValue]; view.x = [prop floatValue];