枚举类型的隐式转换&en; CGImageAlphaInfo'不同的枚举类型' CGBitmapinfo' (又名)' enum CGBitmapInfo')ios 7

时间:2014-06-10 11:28:08

标签: ios enums

您好在应用程序中使用谷歌地图中的路线方向,我需要更新路线,同时更新它显示一些警告,如。

  

从枚举类型'枚举CGImageAlphaInfo'到...的隐式转换   不同的枚举类型'CGBitmapinfo'(又名)'枚举CGBitmapInfo')

这是我的代码。

     -(void) updateRouteView {

         CGContextRef context =     CGBitmapContextCreate(nil,
                                              routeView.frame.size.width,
                                              routeView.frame.size.height,
                                              8,
                                              4 * routeView.frame.size.width,
                                              CGColorSpaceCreateDeviceRGB(),
                                              kCGImageAlphaPremultipliedLast);

       CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
       CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
       CGContextSetLineWidth(context, 3.0);
  }

在上面显示警告线。

  

kCGImageAlphaPremultipliedLast);

在上面的行显示警告,请告诉我如何解决这个问题。

感谢。

3 个答案:

答案 0 :(得分:4)

CGBitmapContextCreate

的语法
CGContextRef CGBitmapContextCreate (
   void *data,
   size_t width,
   size_t height,
   size_t bitsPerComponent,
   size_t bytesPerRow,
   CGColorSpaceRef colorspace,
   CGBitmapInfo bitmapInfo
);

查看属于CGBitmapInfo的最后一个参数。但您使用的kCGImageAlphaPremultipliedLast属于CGImageAlphaInfo。所以只需将类型转换为CGBitmapInfo

答案 1 :(得分:0)

更新您的代码

CGContextRef context =CGBitmapContextCreate(nil,routeView.frame.size.width, routeView.frame.size.height,8,4 * routeView.frame.size.width, CGColorSpaceCreateDeviceRGB(), kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast);

答案 2 :(得分:0)

我刚刚添加了#34;(CGBitmapInfo)"它的工作原理

-(void) updateRouteView {

         CGContextRef context =     CGBitmapContextCreate(nil,
                                              routeView.frame.size.width,
                                              routeView.frame.size.height,
                                              8,
                                              4 * routeView.frame.size.width,
                                              CGColorSpaceCreateDeviceRGB(),
                                              (CGBitmapInfo)kCGImageAlphaPremultipliedLast);

       CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
       CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
       CGContextSetLineWidth(context, 3.0);
  }