2012-02-07 63 views
0

我已經使用corePlot_0.4庫創建了Piechart(CPTGraphHostingView)。 Piechart正確顯示在帶有labelforPiechart的UIView上, 同樣從該餅圖視圖中我創建了通過電子郵件發送的圖像。但是,雖然我從使用GraphicsContext的餅圖視圖獲取圖像,但只有圖像上顯示的餅圖標籤不可見。Piechart標籤在圖像上不可見

下面是我從餅圖視圖獲取圖像的代碼:

// Get the image from piechartview 

-(UIImage *) GetImageFromView{ 
    if (NULL != UIGraphicsBeginImageContextWithOptions) 
       UIGraphicsBeginImageContextWithOptions PieChartView.bounds.size, NO, 0); 
      else 
       UIGraphicsBeginImageContext(PieChartView.view.bounds.size); 

      CGContextRef context = UIGraphicsGetCurrentContext(); 
      CGContextSaveGState(context);    
      [rpsvc.view.layer renderInContext:context]; 
      CGContextRestoreGState(context); 

      UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 

      UIGraphicsEndImageContext();  
    return image; 
    } 

回答

1

我有同樣的問題。看起來,如果沒有爲圖形設置背景,則某些圖像查看器無法看到標籤。

試試這個;

CPTColor *background_colour = [CPTColor colorWithComponentRed:0 green:0 blue:0 alpha:1]; 
graph.fill = [CPTFill fillWithColor:background_colour]; 

它只是將圖形的背景顏色設置爲黑色並設置alpha。