只是试着用:
var context = CGBitmapContextCreate(nil,
self.bounds.width as UInt,
self.bounds.height as UInt,
8,
nil,
CGColorSpaceCreateDeviceRGB(),
kCGBitmapByteOrder32Big)但是它说kCGBitmapByteOrder32Big是未解决的标识符。但是我在堆栈溢出中找到了许多这样的例子,但是对于objectiveC来说却是如此。问:如何输入/获取CGBitmapInfo
正确的语法:
var context:CGContextRef = CGBitmapContextCreate(nil,
UInt(self.bounds.width),
UInt(self.bounds.height),
8,
0,
CGColorSpaceCreateDeviceRGB(),
CGBitmapInfo.ByteOrder32Big)发布于 2014-09-17 14:33:03
在Swift中,这应该是CGBitmapInfo.ByteOrder32Big。您可以将其作为.ByteOrder32Big传递,因为CGBitmapInfo类型已经知道。
通常,TypeValue或kTypeValue形式的ObjC/CoreFoundation枚举都是Swift中的Type.Value。
您将把nil传递为bytesPerRow。我想你是说0。nil不是一回事(尽管它可能在ObjC中适用于您)。
https://stackoverflow.com/questions/25893098
复制相似问题