Converting UIColor to CGColor in swift

Shakti Chauhan picture Shakti Chauhan · Jan 7, 2015 · Viewed 59.6k times · Source

This is the Obj-C code:

CGContextSetStrokeColorWithColor(context, [[UIColor lightGrayColor] CGColor]);

How do I write it in swift.

Answer

Onik IV picture Onik IV · Jan 7, 2015
// Original answer.
var newColor = UIColor.lightGrayColor().CGColor

// Swift 3 version
var newColor = UIColor.lightGray.cgColor