CGFloat R, G, B; CGColorRef color = [UIColor clearColor].CGColor; // Returns the number of color components (including alpha) associated with a Quartz color NSInteger numComponents = CGColorGetNumberOfComponents(color); if (numComponents == 4) { const CGFloat *components = CGColorGetComponents(color); R = components[0]; G = components[1]; B = components[2]; } NSLog(@"r= %f,g=%f,b=%f",R,G,B);
输出为 :r=0.000000,g=0.000000,b=0.000000