iOS: implements multiple segments as gradient color
This commit is contained in:
parent
d91142a1db
commit
6406bfdcef
@ -341,8 +341,20 @@ - (void)requestLayout {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.gradientSize = self.view.frame.size;
|
self.gradientSize = self.view.frame.size;
|
||||||
|
NSMutableArray *colors = [[NSMutableArray alloc] init];
|
||||||
|
if ([dict objectForKey:@"colors"] != nil) {
|
||||||
|
NSMutableArray *array = [dict mutableArrayValueForKey:@"colors"];
|
||||||
|
[array forEach:^(id obj) {
|
||||||
|
[colors addObject:(__bridge id) DoricColor(obj).CGColor];
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
UIColor *start = DoricColor(dict[@"start"]);
|
UIColor *start = DoricColor(dict[@"start"]);
|
||||||
UIColor *end = DoricColor(dict[@"end"]);
|
UIColor *end = DoricColor(dict[@"end"]);
|
||||||
|
|
||||||
|
[colors addObject:(__bridge id) start.CGColor];
|
||||||
|
[colors addObject:(__bridge id) end.CGColor];
|
||||||
|
}
|
||||||
|
|
||||||
int orientation = [dict[@"orientation"] intValue];
|
int orientation = [dict[@"orientation"] intValue];
|
||||||
CGPoint startPoint;
|
CGPoint startPoint;
|
||||||
CGPoint endPoint;
|
CGPoint endPoint;
|
||||||
@ -371,7 +383,7 @@ - (void)requestLayout {
|
|||||||
startPoint = CGPointMake(0, 0);
|
startPoint = CGPointMake(0, 0);
|
||||||
endPoint = CGPointMake(0, 1);
|
endPoint = CGPointMake(0, 1);
|
||||||
}
|
}
|
||||||
UIImage *gradientImage = [self gradientImageFromColors:@[(__bridge id) start.CGColor, (__bridge id) end.CGColor]
|
UIImage *gradientImage = [self gradientImageFromColors:colors
|
||||||
startPoint:startPoint
|
startPoint:startPoint
|
||||||
endPoint:endPoint
|
endPoint:endPoint
|
||||||
imgSize:self.gradientSize];
|
imgSize:self.gradientSize];
|
||||||
|
Reference in New Issue
Block a user