2012-05-08 82 views
0

我嘗試使用此功能繪圖線5

-(IBAction) DrawLine 
{ 
    CGContextRef c = UIGraphicsGetCurrentContext(); 

     CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f}; 
     CGContextSetStrokeColor(c, red); 
     CGContextBeginPath(c); 
     CGContextMoveToPoint(c, 5.0f, 5.0f); 
     CGContextAddLineToPoint(c, 50.0f, 50.0f); 
     CGContextStrokePath(c); 
} 

繪製的目標C線,但我發現,c爲空或爲零,爲什麼?什麼是解決方案?

回答