How to set UIColor
value into CGContextSetRGBStrokeColor
// This is red color which i set to the CGContextSetRGBStrokeColor
CGContextSetRGBStrokeColor(contextRef, 1, 0, 0,1.00f);
Now i do have UIColor which has RGB value i need to set this value to CGContextSetRGBStrokeColor
.
Any one suggest me how to set UIColor
value's CGContextSetRGBStrokeColor
Alternative:
CGContextSetStrokeColorWithColor(context, [[UIColor greenColor] CGColor]);
// or
[[UIColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:1.0f] CGColor];
CGFloat red, green, blue, alpha;
[color getRed:&red green:&green blue:&blue alpha:&alpha];
CGContextSetRGBStrokeColor(contextRef, red, green, blue, alpha);
For the lazy :
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);
#SwiftStyle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With