码迷,mamicode.com
首页 > 移动开发 > 详细

iOS获取UIColor对象的RGB值

时间:2015-01-06 12:04:52      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:




- (NSDictionary *)getRGBDictionaryByColor:(UIColor *)originColor

{

  CGFloat r=0,g=0,b=0,a=0;

  if ([self respondsToSelector:@selector(getRed:green:blue:alpha:)]) {

    [originColor getRed:&r green:&g blue:&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获取UIColor对象的RGB值

标签:

原文地址:http://blog.csdn.net/shouqiangwei/article/details/42454755

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!