objective c - iOS - Convert NSArray to float array -


i have array called self.gradientarray of colors. when print out looks this:

gradientsarray: (     "uidevicergbcolorspace 0.333333 0.811765 0.768627 1",     "uidevicergbcolorspace 0.333333 0.811765 0.768627 1" ) 

i want convert array cgfloat array. example this:

cgfloat colors [] = {                 1.0, 1.0, 1.0, 1.0,                 1.0, 0.0, 0.0, 1.0             }; 

i tried , didn't work. i'm new objective-c , syntax please me.

cgfloat colors [] = self.gradientarray; 

i want use cgfloat array in making gradients this:

cggradientref gradient = cggradientcreatewithcolorcomponents(basespace, colors, null, 2); 

the gradientsarray appear array of uicolor, in case like:

nsarray *gradientsarray = @[[uicolor redcolor], [uicolor bluecolor]];  cgfloat colors[gradientsarray.count * 4]; nsinteger index = 0; (uicolor *color in gradientsarray) {     cgfloat red, green, blue, alpha;     [color getred:&red green:&green blue:&blue alpha:&alpha];     colors[index++] = red;     colors[index++] = green;     colors[index++] = blue;     colors[index++] = alpha; } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -