Developer/iOS

[iOS] CGContextSetRGBStrokeColor 색깔 Setting하기

블로blow 2015. 12. 22. 17:40
728x90

Object-C Style

CGFloat red, green, blue, alpha;

red = 1.0f;

CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, alpha);


//or

CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor redColor] CGColor]);


Swift Style

let myUIColor = UIColor.purpleColor()

var r:CGFloat, g:CGFloat, b:CGFloat, a:CGFloat = 0

myUIColor.getRed(&r, green: &g, blue: &b, alpha: &a)

CGContextSetRGBStrokeColor(c, r, g, b, a)


// or

CGContextSetStrokeColorWithColor(myUIColor.CGColor);


728x90