Skip to content

Instantly share code, notes, and snippets.

View sroddy's full-sized avatar

Stefano Rodriguez sroddy

View GitHub Profile
@vibrazy
vibrazy / gradient.m
Created October 24, 2012 21:36
Create a CAGradientLayer from a CSS string in the "background-image(linear-gradient(top, #cb60b3 0%,#c146a1 50%,#a80077 51%,#db36a4 100%));" format
+(CAGradientLayer *)layerFromArray:(NSArray *)gradientsArray
{
//create gradient from gradient
NSMutableArray *arrayOfColors = [NSMutableArray arrayWithCapacity:10];
NSMutableArray *arrayOfPositions = [NSMutableArray arrayWithCapacity:10];
for (NSString *string in gradientsArray)
{
NSArray *arr = [string componentsSeparatedByString:@","];