2010-06-14 40 views
0

我想更新一個UIView子類來繪製個別像素(矩形)後計算,如果他們在mandelbrot集。更新UIView子類的內容

我使用下面的代碼,但我得到一個空白屏幕:

//drawingView.h 

... 

-(void)drawRect:(CGRect)rect{ 

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    CGContextSetRGBFillColor(context, r, g, b, 1); 
    CGContextSetRGBStrokeColor(context, r, g, b, 1); 

    CGRect arect = CGRectMake(x,y,1,1); 


    CGContextFillRect(context, arect); 

} 
... 

//viewController.m 
... 
- (void)viewDidLoad { 
    [drawingView setX:10]; 
    [drawingView setY:10]; 
    [drawingView setR:0.0]; 
    [drawingView setG:0.0]; 
    [drawingView setB:0.0]; 
    [super viewDidLoad]; 
    [drawingView setNeedsDisplay]; 
} 

一旦我弄清楚如何顯示一個像素,我想知道如何去通過添加另一個更新視圖像素(一次計算)。一旦所有變量發生變化,我如何保持當前視圖的狀態,但添加另一個像素?

感謝, 佈雷特

回答

0
CGContextMoveToPoint(context, xcoord, ycoord); 
CGContextAddLineToPoint(context, xcoord, ycoord); 
CGContextStrokePath(context);