iphone-common-codes-ccteam源代码 CCUIColor.m
来源:互联网 发布:淘宝访问深度 编辑:程序博客网 时间:2024/05/16 09:29
//// CCUIColor.m// CCFC//// Created by xichen on 11-12-17.// Copyright 2011年 ccteam. All rights reserved.//#import "CCUIColor.h"@implementation UIColor(cc)// 获取UIColor的RGBA的值- (void)getRGBAValue:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha{ CGColorRef colorRef = [self CGColor]; const CGFloat *tmComponents = CGColorGetComponents(colorRef); if(red) *red = tmComponents[0]; if(green) *green = tmComponents[1]; if(blue) *blue = tmComponents[2]; if(alpha) *alpha = tmComponents[3];}- (CGFloat)getRedValue{ CGColorRef colorRef = [self CGColor]; const CGFloat *tmComponents = CGColorGetComponents(colorRef); return tmComponents[0];}- (CGFloat)getGreenValue{ CGColorRef colorRef = [self CGColor]; const CGFloat *tmComponents = CGColorGetComponents(colorRef); return tmComponents[1];}- (CGFloat)getBlueValue{ CGColorRef colorRef = [self CGColor]; const CGFloat *tmComponents = CGColorGetComponents(colorRef); return tmComponents[2];}- (CGFloat)getAlphaValue{ CGColorRef colorRef = [self CGColor]; const CGFloat *tmComponents = CGColorGetComponents(colorRef); return tmComponents[3];}// 由RGB的值获得CGColorRef指针// you should release the returnValue by your hand.+ (CGColorRef)createCGColorRefByRGB:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha{ CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); const CGFloat rgbColor[] = {(float)red / 255, (float)green / 255 , (float) blue / 255, (float) alpha / 255}; CGColorRef color = CGColorCreate(rgb, rgbColor); CGColorSpaceRelease(rgb); return color;}// print the RGBA info of the UIColor- (void)printRGBA{ CGColorRef colorRef = [self CGColor]; const CGFloat *tmComponents = CGColorGetComponents(colorRef); NSLog(@"%@ R:%f, G:%f, B:%f, A:%f", self, tmComponents[0], tmComponents[1], tmComponents[2], tmComponents[3]);}@end
可能有更新:
googlecode链接地址:http://code.google.com/p/iphone-common-codes-ccteam/source/browse/trunk/CCFC/files/CCUIColor.m
github地址: https://github.com/cxsjabc/iphone-common-codes-ccteam/tree/master/CCFC/files/CCUIColor.m
- iphone-common-codes-ccteam源代码 CCUIColor.m
- iphone-common-codes-ccteam源代码 CCUIColor.h
- iphone-common-codes-ccteam源代码 CCAddressBook.m
- iphone-common-codes-ccteam源代码 CCAutoDisappearView.m
- iphone-common-codes-ccteam源代码 CCBaseTipView.m
- iphone-common-codes-ccteam源代码 CCCALayer.m
- iphone-common-codes-ccteam源代码 CCCamera.m
- iphone-common-codes-ccteam源代码 CCCommon.m
- iphone-common-codes-ccteam源代码 CCCompile.m
- iphone-common-codes-ccteam源代码 CCConfig.m
- iphone-common-codes-ccteam源代码 CCContact.m
- iphone-common-codes-ccteam源代码 CCDelete.m
- iphone-common-codes-ccteam源代码 CCDepend.m
- iphone-common-codes-ccteam源代码 CCDylib.m
- iphone-common-codes-ccteam源代码 CCEmoji.m
- iphone-common-codes-ccteam源代码 CCEncoding.m
- iphone-common-codes-ccteam源代码 CCFile.m
- iphone-common-codes-ccteam源代码 CCFileName.m
- iphone-common-codes-ccteam源代码 CCUICalloutView.h
- iphone-common-codes-ccteam源代码 CCUICalloutView.m
- iphone-common-codes-ccteam源代码 CCUIColor.h
- 练就金睛火眼 从进程中判断病毒和木马
- CSS的选择器
- iphone-common-codes-ccteam源代码 CCUIColor.m
- 分隔符
- 分享一个非常好的网站
- 权限分配(级联复选框操作)
- CSS 的优先级机制[总结]
- 购票程序指南
- 2011考试惨败呈照
- 删除单个文件
- Twig 的 tags学习(中文) 之三 完结