Search code examples
iosswift3swift2cgbitmapcontextcreate

Swift 2&3: How to Use CGBitmapContextCreate


I have the following code:

let ref:CGContextRef = CGBitmapContextCreate(nil , 200, 130, CGImageGetBitsPerComponent(self.CGImage), 0, CGImageGetColorSpace(self.CGImage), CGImageGetBitmapInfo(self.CGImage))

The problem is that I get this error:

Expression does not conform to type 'NilLieralConvertible'

What should I pass in instead of nil for the first argument and why?


Solution

  • The problem is the last argument. Make the last argument CGImageGetBitmapInfo(self.CGImage).rawValue.