Search code examples
objective-cswiftcolorsuicolor

Converting UIColor to CGColor in swift


This is the Obj-C code:

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

How do I write it in swift.


Solution

  • // Original answer.
    var newColor = UIColor.lightGrayColor().CGColor
    
    // Swift 3 version
    var newColor = UIColor.lightGray.cgColor