forked from rickyzhang82/tethering
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ColorC.mm
36 lines (29 loc) · 943 Bytes
/
ColorC.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// ColorC.m
// SOCKS
//
// Created by Daniel Sachse on 10/30/10.
// Copyright 2010 coffeecoding. All rights reserved.
//
#import "ColorC.h"
@implementation UIColor(ColorC)
// helper function
+(CGColorRef)createRGBValue:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha
{
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat components[4] = {red, green, blue, alpha};
CGColorRef color = CGColorCreate(colorspace, components);
CGColorSpaceRelease(colorspace);
return color;
}
// create and return the new UIColor
+(UIColor *)colorFromRGBIntegers:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha
{
CGFloat redF = red/255;
CGFloat greenF = green/255;
CGFloat blueF = blue/255;
CGFloat alphaF = alpha/1.0f;
CGColorRef color = [UIColor createRGBValue:redF green:greenF blue:blueF alpha:alphaF];
return [UIColor colorWithCGColor:color];
}
@end