`
1021082712
  • 浏览: 84190 次
  • 性别: Icon_minigender_2
  • 来自: 武汉
社区版块
存档分类
最新评论

UIColor 获取颜色的RGB值

    博客分类:
  • ios
阅读更多
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

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics