/**
* gets The RGB value of the Uicolor object .
*
* @param origincolor
*
* @return
*/
-(nsstring *) Gethexstringbycolor: (uicolor *) origincolor
{
nsdictionary *colordic= [ self getrgbdictionarybycolor: Origincolor];
int r = [colordic[@ "R"]floatvalue] * 255;
int g = [colordic[@ "G"]floatvalue] * 255;
int b = [colordic[@ "B"]floatvalue] * 255;
nsstring *red = [nsstringstringwithformat:@ "%02x", R];
nsstring *green = [nsstringstringwithformat:@ "%02x", G];
nsstring *blue = [nsstringstringwithformat:@ "%02x", b];
return [nsstringstringwithformat:@ "#%@%@%@", red, green, blue];
}
-(nsdictionary *) Getrgbdictionarybycolor: (uicolor *) origincolor
{
cgfloat r=0, g=0, b=0, a=0;
if ([ self respondstoselector:@selector(getRed:green:blue:alpha:)]) {
[Origincolorgetred: &r green: &gBlue: &b Alpha:&a];
}
Else {
Const cgfloat *components =cgcolorgetcomponents(origincolor. Cgcolor);
r = components[0];
g = components[1];
b = components[2];
A = components[3];
}
return @{@ "R":@ (R),
@ "G":@ (g),
@ "B":@ (b),
@ "A":@ (a)};
}
IOS gets the RGB value of the Uicolor object.